Class JsonReader

java.lang.Object
com.badlogic.gdx.utils.JsonReader
All Implemented Interfaces:
BaseJsonReader

public class JsonReader extends Object implements BaseJsonReader
Lightweight JSON parser.

The default behavior is to parse the JSON into a DOM containing JsonValue objects. Extend this class and override methods to perform event driven parsing. When this is done, the parse methods will return null.
  • Constructor Details

    • JsonReader

      public JsonReader()
  • Method Details

    • parse

      public JsonValue parse(String json)
    • parse

      public JsonValue parse(Reader reader)
    • parse

      public JsonValue parse(InputStream input)
      Specified by:
      parse in interface BaseJsonReader
    • parse

      public JsonValue parse(FileHandle file)
      Specified by:
      parse in interface BaseJsonReader
    • parse

      public JsonValue parse(char[] data, int offset, int length)
    • stop

      public void stop()
      Causes parsing to stop after the current or next object, array, or value.
    • isStopped

      public boolean isStopped()
    • startObject

      protected void startObject(@Null String name)
      Called when an object is encountered in the JSON.
    • startArray

      protected void startArray(@Null String name)
      Called when an array is encountered in the JSON.
    • pop

      protected void pop()
      Called when the end of an object or array is encountered in the JSON.
    • string

      protected void string(@Null String name, String value)
      Called when a string value is encountered in the JSON.
    • number

      protected void number(@Null String name, double value, String stringValue)
      Called when a double value is encountered in the JSON.
    • number

      protected void number(@Null String name, long value, String stringValue)
      Called when a long value is encountered in the JSON.
    • bool

      protected void bool(@Null String name, boolean value)
      Called when a boolean value is encountered in the JSON.
    • unescape

      protected String unescape(String value)
      Called to unescape string values. The default implementation does standard JSON unescaping.