Package io.nats.jparse.parser.functable
Class JsonFuncParser
- java.lang.Object
-
- io.nats.jparse.parser.functable.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
-
-
Field Summary
-
Fields inherited from interface io.nats.jparse.node.support.ParseConstants
A, A_, ARRAY_END_TOKEN, ARRAY_SEP, ARRAY_START_TOKEN, ATTRIBUTE_SEP, B, B_, C, C_, CARRIAGE_RETURN_WS, CONTROL_ESCAPE_TOKEN, D, D_, DECIMAL_POINT, DEL, DOT, E, E_, ETX, EXPONENT_MARKER, EXPONENT_MARKER2, F, F_, FALSE_BOOLEAN_START, G, G_, H, H_, I, I_, INDEX_BRACKET_END_TOKEN, INDEX_BRACKET_START_TOKEN, J, J_, K, K_, L, L_, M, M_, MAX_INT_STR, MAX_INT_STR_LENGTH, MAX_LONG_STR, MAX_LONG_STR_LENGTH, MIN_INT_STR, MIN_INT_STR_LENGTH, MIN_LONG_STR, MIN_LONG_STR_LENGTH, MINUS, N, N_, NEST_LEVEL, NEW_LINE_WS, NULL_START, NUM_0, NUM_1, NUM_2, NUM_3, NUM_4, NUM_5, NUM_6, NUM_7, NUM_8, NUM_9, O, O_, OBJECT_ATTRIBUTE_SEP, OBJECT_END_TOKEN, OBJECT_START_TOKEN, P, P_, PLUS, Q, Q_, R, R_, S, S_, SINGLE_QUOTE, SPACE_WS, STRING_END_TOKEN, STRING_START_TOKEN, T, T_, TAB_WS, TRUE_BOOLEAN_START, U, U_, V, V_, W, W_, X, X_, Y, Y_, Z, Z_
-
-
Constructor Summary
Constructors Constructor Description JsonFuncParser(boolean objectsKeysCanBeEncoded, ParseFunction[] funcTable, ParseFunction defaultFunc, ParsePartFunction parseKey)
Create a new `JsonFuncParser` with the default function table.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RootNode
parse(CharSource source)
Parse a character source and return a root node representing the parsed JSON.java.util.List<Token>
scan(CharSource source)
Scan a character source and return a list of tokens representing the JSON string.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.nats.jparse.parser.JsonParser
parse, scan
-
-
-
-
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 parsingfuncTable
- function tabledefaultFunc
- 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 interfaceJsonParser
- 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 interfaceJsonParser
- Parameters:
source
- The character source to parse- Returns:
- A root node representing the parsed JSON
-
-