JsonPrinter¶
Serialize any JsonValue to a JSON string. This is the dual of JsonParser:
where JsonParser.parse turns a String into a JsonValue, JsonPrinter
turns a JsonValue back into a JSON String.
To serialize Pony data as JSON, build a JsonValue and pass it to print:
let doc = JsonObject
.update("name", "Alice")
.update("age", I64(30))
env.out.print(JsonPrinter.print(doc))
// {"name":"Alice","age":30}
print produces compact output; pretty produces indented output. Both
accept any JsonValue, including scalars (String, I64, F64, Bool)
and JSON null (None):
Constructors¶
create¶
Returns¶
- JsonPrinter val^
Public Functions¶
print¶
Compact JSON serialization of any JsonValue.
Parameters¶
- value: JsonValue
Returns¶
- String iso^
pretty¶
Pretty-printed JSON serialization of any JsonValue.
Parameters¶
Returns¶
- String iso^
eq¶
Parameters¶
- that: JsonPrinter val
Returns¶
- Bool val
ne¶
Parameters¶
- that: JsonPrinter val
Returns¶
- Bool val