Using the following code, I am able to format (beautify) JSON using the built-in Delphi functions from the System.JSON
unit:
function FormatJson(json: String; IndentationCount: Cardinal): String;
begin
try
var JsonObject := TJSONObject.ParseJSONValue(json) as TJSONObject;
Result := JsonObject.Format(IndentationCount);
except
on E:Exception do
begin
// Error in JSON syntax
end;
end;
end;
Is there a built-in function to do the opposite in Delphi? I want to minify my JSON.
If there isn't a built-in method, does anyone have a function written to minify JSON?