Pre-defined pretty printers
Once you have using the Json data type in scala, you are going to need to safely convert that back to a json string.
You may want to print that in a compact format for a wire transport, or a format
better suited for visual inspection. To assist we expose a number of predefined
printers on the Json
data type.
Produces:
/** compact **/ {"blue":false,"red":true} /** formatted with 2 spaces **/ { "red" : true, "blue" : false } /** formatted with 4 spaces **/ { "red" : true, "blue" : false }
Custom pretty printers
As with the entire argonaut library, pretty printing aims to make
things as easy as possible - but not at the cost of flexibility or
power. We expose the general pretty
method that takes
a PrettyParams
configuration to customise all aspects
of Json string generation.
For example, if we wanted to use two spaces, but not prefix the colon with a space, then we could tweak the default 2 space format:
Produces
{ "red": true, "blue": false }