klyn.io.json.JSON.parse
method
public static parse(notnull json as String) as Object
Description

Parses JSON text into its natural Klyn representation.

JSON objects become maps, arrays become array lists, and scalar values retain their corresponding primitive type. Integer tokens produce Int within its signed 32-bit range and Long otherwise. Tokens with a decimal point or exponent produce Double.

Parameters
ParameterDescription
jsonJSON document to parse.
Returns

Parsed map, list, scalar value, or null.

Throws
  • JSONParseException if the document is malformed or a number is outside the supported Long/Double range. Escaped U+0000 is supported in both keys and string values.
  • NullException if json is null at runtime; statically null arguments are rejected with TypeError.
Example
value = JSON.parse("""{"numerator": 1, "denominator": 3}""")
assert value is SortedMap
assert JSON.parse("2147483648") is Long