minify

fnbool minify(out string output, const(char)[] input, out JsonError err) @safe

Minify JSON text by removing all optional whitespace.

This function preserves exact token representations (number formats, string escape sequences) while removing all whitespace between tokens.

Parameters

outputOutput parameter for the minified JSON string.
inputJSON text to minify.
errOutput parameter for error information on failure.

Returns

true on success; false with err populated on lexical/syntax error.

Examples

import ddn.data.json : minify, JsonError;

string result;
JsonError err;
assert(minify(result, `{ "a" : 1 , "b" : [ 2 , 3 ] }`, err));
assert(result == `{"a":1,"b":[2,3]}`);
fnstring minify(const(char)[] input) @safe

Convenience overload that minifies JSON and returns the result directly.

Parameters

inputJSON text to minify.

Returns

The minified JSON string, or an empty string on error.