Class JSONParser

java.lang.Object
org.rumbledb.items.parsing.JSONParser

public final class JSONParser extends Object
Parser for JSON texts used by fn:parse-json and fn:json-doc.

The parser converts JSON values to RumbleDB items. It supports the parse-json options liberal, duplicates, escape, and fallback.

If liberal is false, the input must follow the JSON grammar strictly. If liberal is true, this implementation accepts selected JSON extensions, including:

  • single-quoted strings
  • unquoted object keys
  • comments
  • trailing commas
  • leading plus signs
  • leading zeroes
  • unescaped control characters

String parsing keeps two representations:

  • resultValue: the string value stored in the resulting item
  • keyComparisonValue: the value used to detect duplicate object keys

These can differ when escape=false and invalid XML characters are replaced using the fallback function.