Doesn’t pretty printing of JSON strings with JSON.jl work? The README doesn’t explicitly mention pretty printing, but indentation is mentioned all over the code and there are print
methods with an indentation parameter.
Here’s the sample JSON string from the README page and my attempt at printing it with 4 spaces of indentation:
julia> s = "{\"a_number\" : 5.0, \"an_array\" : [\"string\", 9]}"
"{\"a_number\" : 5.0, \"an_array\" : [\"string\", 9]}"
julia> JSON.print(s,4)
"{\"a_number\" : 5.0, \"an_array\" : [\"string\", 9]}"
And here’s another sample if someone wants to test something with a bit of nesting.
ss = "{\"breakpoints\":{\"1\":{\"year\":2015,\"value\":33.3,\"unit\":1},\"2\":{\"year\":2040,\"value\":40,\"unit\":1},\"3\":{\"year\":2050,\"value\":40,\"unit\":1},\"4\":{\"year\":2100,\"value\":0,\"unit\":2}},\"parameter\":2.2}"