Class Json5ParserSession
- All Implemented Interfaces:
BeanSession,ConverterSession,ArrayRecordReadable,RecordReadable,TokenReadable
- Direct Known Subclasses:
Json5lParserSession
Json5Parser.
Extends JsonParserSession to support JSON5 syntax including unquoted attribute names,
single-quoted strings, string concatenation, JavaScript comments, and relaxed number formats.
Notes:
- This class is not thread safe and is typically discarded after one use.
See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.juneau.marshall.json.JsonParserSession
JsonParserSession.DefaultBuilder -
Field Summary
Fields inherited from class org.apache.juneau.marshall.parser.ParserSession
DEFAULT_MAX_PARSE_DEPTHFields inherited from class org.apache.juneau.marshall.MarshallingSession
NAME_PROPERTY_NAME -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanReturns whether trailing commas are accepted before] /} in the databind path.protected booleanReturns whether non-string types can be coerced to strings usingnewInstanceFromString().static Json5ParserSession.Buildercreate(Json5Parser ctx) Creates a new builder for this object.protected booleanisCommentOrWhitespace(int cp) Returnstrue if the specified character is whitespace or '/'.protected booleanisNumberStartChar(int c) Returnstrue if the specified character can start a number value.protected booleanisWhitespace(int cp) Returnstrue if the specified character is whitespace.protected MarshalledListCreates a generic list for parser-driven list population.protected MarshalledMapCreates a string-keyed generic map for parser-driven map population.protected voidHook called when empty input is detected inreadAnything().protected voidHook called when a missing value is detected inreadAnything().protected Stringprotected NumberreadNumber(ParserReader r, Class<? extends Number> type) protected NumberreadNumber(ParserReader r, String s, Class<? extends Number> type) protected StringreadTokens(Object input) Opens a low-level pull-parser cursor over a JSON5 document, bound to this live session.protected voidMethods inherited from class org.apache.juneau.marshall.json.JsonParserSession
create, doRead, doReadIntoCollection, doReadIntoMap, getJsonClassMeta, isValidateEnd, readArrayRecords, readKeyword, skipCommentsMethods inherited from class org.apache.juneau.marshall.parser.ReaderParserSession
create, createPipe, getStreamCharset, isReaderParser, propertiesMethods inherited from class org.apache.juneau.marshall.parser.ParserSession
allocateLocal, cast, checkRequired, convertAttrToType, create, doReadToBeanConsumer, enterParseDepth, exitParseDepth, getCalendarFormat, getClassMeta, getDateFormat, getDebugOutputLines, getDurationFormat, getInputAsString, getJavaMethod, getLastLocation, getListener, getListener, getListenerClass, getLocaleFormat, getNulls, getOuter, getPeriodFormat, getPosition, getSchema, getStringBuilder, getTemporalFormat, getTimeZoneFormat, isAutoCloseStreams, isTrimStrings, isUnbuffered, mark, onBeanSetterException, onUnknownProperty, parentBean, read, read, read, read, read, read, readArgs, readCalendar, readDate, readDuration, readIntoCollection, readIntoMap, readPeriod, readTemporal, readToBeanConsumer, returnStringBuilder, setCurrentClass, setCurrentProperty, setName, setParent, setPipe, swapParentBean, trim, trim, unmark, unswapMethods inherited from class org.apache.juneau.marshall.MarshallingSession
addWarning, convertToMemberType, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, convertToType, create, get, getActiveView, getAnnotationProvider, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionary, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassLoader, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getLocale, getMarshallingContext, getMediaType, getNotBeanClasses, getNotBeanPackagesNames, getPropertyNamer, getSwaps, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFindFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnoreMissingSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isPropertyInActiveView, isRecordComponentOrder, isUnsortedProperties, isUseInterfaceProxies, isUseJavaBeanIntrospector, isValidateSchema, newBean, newBean, newBeanMap, newBeanMap, newGenericMap, object, parseToList, parseToMap, string, toArray, toBeanMap, toBeanMap, toBeanMapMethods inherited from class org.apache.juneau.marshall.ContextSession
checkForWarnings, getContext, getSessionProperties, getWarnings, isDebug, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.juneau.marshall.stream.ArrayRecordReadable
isArrayRecordStreaming, readArrayRecordsMethods inherited from interface org.apache.juneau.commons.conversion.ConverterSession
getMethods inherited from interface org.apache.juneau.marshall.stream.RecordReadable
isRecordStreamingMethods inherited from interface org.apache.juneau.marshall.stream.TokenReadable
readRecords
-
Constructor Details
-
Json5ParserSession
Constructor.- Parameters:
builder- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Parameters:
ctx- The context creating this session.- Returns:
- A new builder.
-
readTokens
Opens a low-level pull-parser cursor over a JSON5 document, bound to this live session.Same honored/ignored builder properties as
JsonParserSession.readTokens(Object); the JSON5 dialect relaxations (single-quoted strings, bare identifiers, trailing commas, missing values) are applied unconditionally as part of the format.- Specified by:
readTokensin interfaceTokenReadable- Overrides:
readTokensin classJsonParserSession- Parameters:
input- The input. AcceptsReader,CharSequence,InputStream, or.byte []- Returns:
- A new
Json5TokenReader. - Throws:
IOException- If a problem occurred opening the underlying input.
-
readFieldName
- Overrides:
readFieldNamein classJsonParserSession- Throws:
IOExceptionParseException
-
readString
- Overrides:
readStringin classJsonParserSession- Throws:
IOExceptionParseException
-
isNumberStartChar
Description copied from class:JsonParserSessionReturnstrue if the specified character can start a number value.JSON numbers start with a digit,
- , or. . JSON5 subclasses also accept+ ,I (Infinity ), andN (NaN ).- Overrides:
isNumberStartCharin classJsonParserSession- Parameters:
c- The next non-whitespace character.- Returns:
true if a number lexeme should be read from this character.
-
readNumber
protected Number readNumber(ParserReader r, Class<? extends Number> type) throws IOException, ParseException - Overrides:
readNumberin classJsonParserSession- Throws:
IOExceptionParseException
-
readNumber
protected Number readNumber(ParserReader r, String s, Class<? extends Number> type) throws ParseException - Overrides:
readNumberin classJsonParserSession- Throws:
ParseException
-
skipCommentsAndSpace
- Overrides:
skipCommentsAndSpacein classJsonParserSession- Throws:
IOExceptionParseException
-
isCommentOrWhitespace
Description copied from class:JsonParserSessionReturnstrue if the specified character is whitespace or '/'.- Overrides:
isCommentOrWhitespacein classJsonParserSession- Parameters:
cp- The codepoint.- Returns:
true if the specified character is whitespace or '/'.
-
isWhitespace
Description copied from class:JsonParserSessionReturnstrue if the specified character is whitespace.Only 0x20 (space), 0x09 (tab), 0x0A (line feed) and 0x0D (carriage return) are considered whitespace.
- Overrides:
isWhitespacein classJsonParserSession- Parameters:
cp- The codepoint.- Returns:
true if the specified character is whitespace.
-
onEmptyInput
Description copied from class:JsonParserSessionHook called when empty input is detected inreadAnything().- Overrides:
onEmptyInputin classJsonParserSession
-
onMissingValue
Description copied from class:JsonParserSessionHook called when a missing value is detected inreadAnything().- Overrides:
onMissingValuein classJsonParserSession
-
allowsTrailingComma
Description copied from class:JsonParserSessionReturns whether trailing commas are accepted before] /} in the databind path.Default returns
false (strict RFC-8259 JSON).Json5ParserSessionoverrides this totrue for the JSON5 dialect.- Overrides:
allowsTrailingCommain classJsonParserSession- Returns:
true if a trailing comma should be silently accepted.
-
canCoerceNonStringToString
Description copied from class:JsonParserSessionReturns whether non-string types can be coerced to strings usingnewInstanceFromString().- Overrides:
canCoerceNonStringToStringin classJsonParserSession- Returns:
- Always
falsefor standard JSON.
-
newGenericMap
Description copied from class:MarshallingSessionCreates a string-keyed generic map for parser-driven map population.This is the main factory hook overridden by per-marshaller parser sessions to return their flavored
XMapvariant (for example,JsonParserSessionreturnsJsonMap;Json5ParserSessionreturnsJson5Map).- Overrides:
newGenericMapin classJsonParserSession- Returns:
- A new map.
-
newGenericList
Description copied from class:MarshallingSessionCreates a generic list for parser-driven list population.Per-marshaller parser sessions override this hook to return their flavored
XListvariant (for example,JsonParserSessionreturnsJsonList;Json5ParserSessionreturnsJson5List).- Overrides:
newGenericListin classJsonParserSession- Returns:
- A new list.
-