Class JsonParserLax

All Implemented Interfaces:
JsonParser

public class JsonParserLax extends JsonParserCharArray
JSON parser variant that also accepts comments, single quotes, and unquoted strings.
  • Constructor Details

    • JsonParserLax

      public JsonParserLax()
      Creates a lax parser with eager value containers and lazy chopping.
    • JsonParserLax

      public JsonParserLax(boolean useValues)
      Creates a lax parser with the supplied value-container mode.
      Parameters:
      useValues - whether to use eager Value containers
    • JsonParserLax

      public JsonParserLax(boolean useValues, boolean chop)
      Creates a lax parser with explicit chopping behavior.
      Parameters:
      useValues - whether to use eager Value containers
      chop - whether to eagerly copy overlay slices
    • JsonParserLax

      public JsonParserLax(boolean useValues, boolean chop, boolean lazyChop)
      Creates a lax parser with explicit lazy chopping behavior.
      Parameters:
      useValues - whether to use eager Value containers
      chop - whether to eagerly copy overlay slices
      lazyChop - whether to defer chopping until values are accessed
    • JsonParserLax

      public JsonParserLax(boolean useValues, boolean chop, boolean lazyChop, boolean defaultCheckDates)
      Creates a lax parser with full overlay configuration.
      Parameters:
      useValues - whether to use eager Value containers
      chop - whether to eagerly copy overlay slices
      lazyChop - whether to defer chopping until values are accessed
      defaultCheckDates - whether strings should be tested for supported date formats
  • Method Details

    • decodeValue

      protected final Object decodeValue()
      Decodes the next value using the parser's lax JSON rules.
      Overrides:
      decodeValue in class JsonParserCharArray
      Returns:
      parsed Groovy JSON value or overlay value
    • decodeNumberLax

      protected final Value decodeNumberLax(boolean minus)
      Decodes a number from a JSON value. If at any point it is determined that the value is not a valid number the value is treated as a String.
      Parameters:
      minus - indicate whether the number is negative
      Returns:
      a number, or String if not a valid number
    • decodeFromChars

      protected final Object decodeFromChars(char[] cs)
      Parses a character buffer and unwraps top-level container values.
      Overrides:
      decodeFromChars in class JsonParserCharArray
      Parameters:
      cs - JSON content to parse
      Returns:
      parsed Groovy JSON value