Signature
DValue json_decode(String s)
Parameters
s : string containing JSON data
return value : a DValue object containing the deserialized JSON data
Deserializes s into a DValue structure.
The returned structure is usually consumed through DValue accessors such as:
tree["key"].to_string()tree["count"].to_u64()tree["enabled"].to_bool()
Current runtime behavior:
JSON objects and arrays become map-shaped
DValuevalues.JSON booleans become native
boolDValuevalues.JSON strings become native
StringDValuevalues.JSON numbers currently deserialize as string-valued
DValuenodes, so typed conversions such asto_f64()andto_u64()are the normal way to read numeric content.
Example
DValue data = json_decode("{\"name\": \"Ada\", \"tags\": [\"x\", \"y\"]}");
print(data["name"].to_string(), " has ", data["tags"].keys().size(), " tags\n");
Output
Ada has 2 tags