prettyjson
PRETTYJSON - use Java JSONObject to produce pretty JSON output
PRETTY = PRETTYJSON(JSON_ENCODED_OBJECT, [SPACESTOINDENTEACHLEVEL])
Given a JSON-encoded object (that is, a JSON string), this function
produces a 'pretty' JSON output that is human-readable (one line per item,
for example).
SPACESTOINDENTEACHLEVEL indicates how many spaces should be used to indent each level.
If it is not provided, 2 is used.
This function calls JSONObject from Java, and requires the org.json.* Java classes.
This library and its addition to the Java path is provided in
http://github.com/VH-Lab/vhlab-thirdparty-matlab. If you have this library you
should be all set.
Example:
mystruct = struct('a',5,'b',3,'c',1);
j = jsonencodenan(mystruct) % produces single line
j_pretty = prettyjson(j) % produces multiple lines
% or a single line:
j_pretty = prettyjson(jsonencodenan(mystruct))