Class JsonParserUsingCharacterSource

java.lang.Object
org.apache.groovy.json.internal.BaseJsonParser
org.apache.groovy.json.internal.JsonParserUsingCharacterSource
All Implemented Interfaces:
JsonParser

public class JsonParserUsingCharacterSource extends BaseJsonParser
Converts an input JSON String into Java objects works with String or char array as input. Produces an Object which can be any of the basic JSON types mapped to Java.
  • Field Details

    • NULL

      protected static final char[] NULL
      Character buffer for the null literal.
    • TRUE

      protected static final char[] TRUE
      Character buffer for the true literal.
    • FALSE

      protected static char[] FALSE
      Character buffer for the false literal.
  • Constructor Details

    • JsonParserUsingCharacterSource

      public JsonParserUsingCharacterSource()
  • Method Details

    • exceptionDetails

      protected String exceptionDetails(String message)
      Builds an error message using the current character source state.
      Parameters:
      message - parser-specific message
      Returns:
      formatted error details
    • decodeJsonObject

      protected final Object decodeJsonObject()
      Decodes a JSON object from the current character source position.
      Returns:
      parsed object as a LazyMap
    • complain

      protected final void complain(String complaint)
      Throws a JsonException for the current source location.
      Parameters:
      complaint - message describing the parse failure
    • decodeNull

      protected final Object decodeNull()
      Consumes the null literal.
      Returns:
      null
    • decodeTrue

      protected final boolean decodeTrue()
      Consumes the true literal.
      Returns:
      true
    • decodeFalse

      protected final boolean decodeFalse()
      Consumes the false literal.
      Returns:
      false
    • decodeJsonArray

      protected final List decodeJsonArray()
      Decodes a JSON array from the current character source position.
      Returns:
      parsed array contents
    • parse

      public Object parse(Reader reader)
      Parses JSON from a reader-backed character source.
      Specified by:
      parse in interface JsonParser
      Overrides:
      parse in class BaseJsonParser
      Parameters:
      reader - reader supplying JSON content
      Returns:
      parsed Groovy JSON value
    • parse

      public Object parse(char[] chars)
      Parses JSON from a character array.
      Parameters:
      chars - JSON content to parse
      Returns:
      parsed Groovy JSON value