UCE Docs / json_encode

Signature

String json_encode(String s)
String json_encode(DValue t)

Parameters

s : string to encode as a JSON string literal
t : DValue object to be serialized
return value : string containing the JSON result

Serializes either a String or a DValue into JSON notation.

When passed a String, json_encode() returns a quoted and escaped JSON string literal.

When passed a DValue, scalar values are serialized directly and nested map values are emitted as JSON objects.

Example

DValue value;
value["name"] = "Ada";
print(json_encode(value), "\n");
Output
{"name": "Ada"}