Scalar FunctionsDynamic / JSON Functions
dynamic_to_json
Serializes a dynamic value to a canonical JSON string: compact (no whitespace), with property-bag keys sorted at every depth and array order kept.
Two bags that hold the same keys and values give the same string whatever their insertion order, so the result can be compared, hashed or grouped on. Reals keep their fraction (1.0), and datetimes inside a bag or array render as ISO 8601 with seven fractional digits. A scalar is not quoted: a dynamic string gives its raw text, a number its digits, and dynamic(null) gives the empty string. Use tostring() to keep the bag's own key order instead.
Syntax
dynamic_to_json(value)Parameters
Prop
Type
Returns: string
Examples
Example 1
print dynamic_to_json(dynamic({"weapon":"axe", "warrior":"Ragnar", "raids":[1793, 795]}))| print_0 (string) |
|---|
| {"raids":[1793,795],"warrior":"Ragnar","weapon":"axe"} |
Example 2
print same = dynamic_to_json(dynamic({"a":1, "b":2})) == dynamic_to_json(
dynamic({"b":2, "a":1})
)| same (bool) |
|---|
| true |