Class Json5lParser
- All Implemented Interfaces:
JsonMetaProvider,ArrayRecordReadable,RecordReadable,TokenReadable
Media types
Handles
Description
JSON5L combines the relaxed JSON5 dialect with JSONL's newline-delimited framing. Each non-empty, non-comment line is parsed as a complete JSON5 value (single-quoted strings, unquoted field names, trailing commas, comments, relaxed numbers). Because JSON5 is a strict superset of JSON, this parser also reads plain JSONL input unchanged.
Comment handling follows JSON5 line-by-line: a line that is blank or contains only a comment is
skipped (like a blank line); inline comments within a record's JSON are tolerated. A
Example:
Example input:
// header comment line {name:'Alice',age:30} {name:'Bob',age:25} // trailing comment
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.juneau.marshall.parser.ReaderParser
ReaderParser.DefaultBuilderNested classes/interfaces inherited from class org.apache.juneau.marshall.parser.Parser
Parser.Null -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Json5lParserDefault parser, Accept=application/json5l.Fields inherited from class org.apache.juneau.marshall.json.JsonParser
validateEndFields inherited from class org.apache.juneau.marshall.parser.Parser
autoCloseStreams, consumes, debugOutputLines, listener, nulls, trimStrings, unbufferedFields inherited from class org.apache.juneau.marshall.MarshallingContextable
marshallingContextFields inherited from class org.apache.juneau.marshall.Context
CONTEXT_APPLY_FILTER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates a builder from this context object.static Json5lParser.Buildercreate()Creates a new builder for this object.Create a session builder based on the properties defined on this context.Returns a session to use for this context.Methods inherited from class org.apache.juneau.marshall.json.JsonParser
getJsonBeanPropertyMeta, getJsonClassMeta, isValidateEnd, readArrayRecords, readTokensMethods inherited from class org.apache.juneau.marshall.parser.ReaderParser
getStreamCharset, isReaderParser, propertiesMethods inherited from class org.apache.juneau.marshall.parser.Parser
canHandle, createParserBuilder, doRead, getDebugOutputLines, getListener, getMediaTypes, getNulls, getPrimaryMediaType, isAutoCloseStreams, isTrimStrings, isUnbuffered, read, read, read, read, read, read, readArgs, readIntoCollection, readIntoMap, readWithOuterMethods inherited from class org.apache.juneau.marshall.MarshallingContextable
getDurationFormat, getMarshallingContext, getPeriodFormatMethods inherited from class org.apache.juneau.marshall.Context
createBuilder, getAnnotationProvider, init, 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.marshall.stream.RecordReadable
isRecordStreamingMethods inherited from interface org.apache.juneau.marshall.stream.TokenReadable
readRecords
-
Field Details
-
DEFAULT
Default parser, Accept=application/json5l.
-
-
Constructor Details
-
Json5lParser
Constructor.- Parameters:
builder- The builder for this object.
-
-
Method Details
-
create
Creates a new builder for this object.- Returns:
- A new builder.
-
copy
Description copied from class:ContextCreates a builder from this context object.Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
- Overrides:
copyin classJson5Parser- Returns:
- A new Builder object.
-
createSession
Description copied from class:ContextCreate a session builder based on the properties defined on this context.Use this method for creating sessions where you want to override basic settings. Otherwise, use
Context.getSession()directly.- Overrides:
createSessionin classJson5Parser- Returns:
- A new session builder.
-
getSession
Description copied from class:ContextReturns a session to use for this context.Note that subclasses may opt to return a reusable non-modifiable session.
- Overrides:
getSessionin classJson5Parser- Returns:
- A new session object.
-