Class Json5Parser

All Implemented Interfaces:
JsonMetaProvider, ArrayRecordReadable, RecordReadable, TokenReadable
Direct Known Subclasses:
Json5lParser

public class Json5Parser extends JsonParser
Parses any valid JSON text into a POJO model.
Media types
Handles Content-Type types: application/json5, text/json5
Description
Identical to JsonParser but accepts JSON5 syntax (single quotes, comments, trailing commas, unquoted keys) and uses media type application/json5. Use this parser when the input may contain JSON5-style syntax.
Example input (Map of name/age):

{name:"Alice",age:30}

Complex (nested object + array):

{name:"Alice",age:30,address:{street:"123 Main St",city:"Boston",state:"MA"},tags:["a","b","c"]}

Notes:
  • This class is thread safe and reusable.
See Also:
  • Field Details

    • DEFAULT

      public static final Json5Parser DEFAULT
      Default parser, Accept=application/json5.
  • Constructor Details

  • Method Details

    • create

      public static Json5Parser.Builder create()
      Creates a new builder for this object.
      Returns:
      A new builder.
    • copy

      Description copied from class: Context
      Creates a builder from this context object.

      Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.

      Overrides:
      copy in class JsonParser
      Returns:
      A new Builder object.
    • createSession

      Description copied from class: Context
      Create 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:
      createSession in class JsonParser
      Returns:
      A new session builder.
    • getSession

      Description copied from class: Context
      Returns a session to use for this context.

      Note that subclasses may opt to return a reusable non-modifiable session.

      Overrides:
      getSession in class JsonParser
      Returns:
      A new session object.