Class JsonFuncParser

  • All Implemented Interfaces:
    ParseConstants, JsonParser

    public class JsonFuncParser
    extends java.lang.Object
    implements JsonParser
    The `JsonFuncParser` class implements the `JsonParser` interface using a function table to define the behavior of the parser. The function table is an array of `ParseFunction` objects, one for each possible character value. The function table is used to determine which function to call when parsing a particular character. The function table can be customized by subclassing this class and overriding the `initFuncTable` method. The function table can be configured via the `JsonParserBuilder` and the JsonFuncParser can be created with a `JsonParserBuilder`.
    See Also:
    JsonParserBuilder
    • Constructor Detail

      • JsonFuncParser

        public JsonFuncParser​(boolean objectsKeysCanBeEncoded,
                              ParseFunction[] funcTable,
                              ParseFunction defaultFunc,
                              ParsePartFunction parseKey)
        Create a new `JsonFuncParser` with the default function table. The default function table is defined by the `JsonParserFunctions` class.
        Parameters:
        objectsKeysCanBeEncoded - If true, the parser will encode the keys of objects when parsing
        funcTable - function table
        defaultFunc - default function if no function is found in the table.
        parseKey - the function to parse keys.
        See Also:
        JsonParserFunctions
    • Method Detail

      • scan

        public java.util.List<Token> scan​(CharSource source)
        Scan a character source and return a list of tokens representing the JSON string.
        Specified by:
        scan in interface JsonParser
        Parameters:
        source - The character source to scan
        Returns:
        A list of tokens representing the JSON
      • parse

        public RootNode parse​(CharSource source)
        Parse a character source and return a root node representing the parsed JSON.
        Specified by:
        parse in interface JsonParser
        Parameters:
        source - The character source to parse
        Returns:
        A root node representing the parsed JSON