Class JsonParser


public class JsonParser extends XMQParseIntoDOM
Parse json into the xmq DOM, a port of the parser in json.c. Like the C code the json is translated into calls of the same parse callbacks as the xmq parser uses (element_key, apar_left, attr_key, element_value_text...), so the DOM is built by XMQParseIntoDOM. The C code invokes the callbacks with pointers to decoded strings (DO_CALLBACK_SIM), here the callback buffer is temporarily replaced by the string, see sim. The json conventions: the key "_" holds the element name of an object that has no key (the root, objects in arrays), "_name" is an attribute, "_xmlns" a namespace declaration, "|" a text node, "//" a comment, "_//" a comment outside of the root, "!DOCTYPE" the doctype, an array is an element with the attribute A, a string that looks like a number or a keyword gets the attribute S and a key that is not a valid element name becomes _(_=key).
  • Constructor Details

    • JsonParser

      public JsonParser()
      Creates the json parser.
  • Method Details

    • parseJson

      public boolean parseJson(String buf, String source) throws ParseException
      Parse json.
      Parameters:
      buf - The json source.
      source - A description of where the buffer comes from, for error messages.
      Returns:
      True on success.
      Throws:
      ParseException - If the json cannot be parsed.