APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.utils

public Class JsonReader

extends Object
implements BaseJsonReader
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.utils.BaseJsonReader
Imports
java.io.IOException, .InputStream, .InputStreamReader, .Reader, java.util.Arrays, com.badlogic.gdx.files.FileHandle, com.badlogic.gdx.utils.JsonValue.ValueType

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.
Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private static final byte[]
private static final byte[]
private static final short[]
private static final byte[]
private static final short[]
private static final byte[]
private static final byte[]
private static final byte[]
private static final char[]
private static final byte[]
private JsonValue
private final Array<JsonValue>
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
private JsonValue
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
addChild(String name, JsonValue child)

protected void
bool(String name, boolean value)

Called when a boolean value is encountered in the JSON.

private static byte[]
private static byte[]
private static short[]
private static byte[]
private static short[]
private static byte[]
private static byte[]
private static byte[]
private static char[]
private static byte[]
public boolean
protected void
number(String name, double value, String stringValue)

Called when a double value is encountered in the JSON.

protected void
number(String name, long value, String stringValue)

Called when a long value is encountered in the JSON.

public JsonValue
parse(String json)

public JsonValue
parse(Reader reader)

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

protected void
pop()

Called when the end of an object or array is encountered in the JSON.

protected void
startArray(String name)

Called when an array is encountered in the JSON.

protected void
startObject(String name)

Called when an object is encountered in the JSON.

public void
stop()

Causes parsing to stop after the current or next object, array, or value.

protected void
string(String name, String value)

Called when a string or null value is encountered in the JSON.

protected String
unescape(String value)

Called to unescape string values.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_json_actionsback to summary
private static final byte[] _json_actions
_json_eof_actionsback to summary
private static final byte[] _json_eof_actions
_json_index_offsetsback to summary
private static final short[] _json_index_offsets
_json_indiciesback to summary
private static final byte[] _json_indicies
_json_key_offsetsback to summary
private static final short[] _json_key_offsets
_json_range_lengthsback to summary
private static final byte[] _json_range_lengths
_json_single_lengthsback to summary
private static final byte[] _json_single_lengths
_json_trans_actionsback to summary
private static final byte[] _json_trans_actions
_json_trans_keysback to summary
private static final char[] _json_trans_keys
_json_trans_targsback to summary
private static final byte[] _json_trans_targs
currentback to summary
private JsonValue current
elementsback to summary
private final Array<JsonValue> elements
json_en_arrayback to summary
pack-priv static final int json_en_array
json_en_mainback to summary
pack-priv static final int json_en_main
json_en_objectback to summary
pack-priv static final int json_en_object
json_errorback to summary
pack-priv static final int json_error
json_first_finalback to summary
pack-priv static final int json_first_final
json_startback to summary
pack-priv static final int json_start
rootback to summary
private JsonValue root
stopback to summary
private boolean stop

Constructor Detail

JsonReaderback to summary
public JsonReader()

Method Detail

addChildback to summary
private void addChild(String name, JsonValue child)
boolback to summary
protected void bool(String name, boolean value)

Called when a boolean value is encountered in the JSON.

init__json_actions_0back to summary
private static byte[] init__json_actions_0()
init__json_eof_actions_0back to summary
private static byte[] init__json_eof_actions_0()
init__json_index_offsets_0back to summary
private static short[] init__json_index_offsets_0()
init__json_indicies_0back to summary
private static byte[] init__json_indicies_0()
init__json_key_offsets_0back to summary
private static short[] init__json_key_offsets_0()
init__json_range_lengths_0back to summary
private static byte[] init__json_range_lengths_0()
init__json_single_lengths_0back to summary
private static byte[] init__json_single_lengths_0()
init__json_trans_actions_0back to summary
private static byte[] init__json_trans_actions_0()
init__json_trans_keys_0back to summary
private static char[] init__json_trans_keys_0()
init__json_trans_targs_0back to summary
private static byte[] init__json_trans_targs_0()
isStoppedback to summary
public boolean isStopped()
numberback to summary
protected void number(String name, double value, String stringValue)

Called when a double value is encountered in the JSON.

numberback to summary
protected void number(String name, long value, String stringValue)

Called when a long value is encountered in the JSON.

parseback to summary
public JsonValue parse(String json)
parseback to summary
public JsonValue parse(Reader reader)
parseback to summary
public JsonValue parse(InputStream input)

Implements com.badlogic.gdx.utils.BaseJsonReader.parse.

parseback to summary
public JsonValue parse(FileHandle file)

Implements com.badlogic.gdx.utils.BaseJsonReader.parse.

parseback to summary
public JsonValue parse(char[] data, int offset, int length)
popback to summary
protected void pop()

Called when the end of an object or array is encountered in the JSON.

startArrayback to summary
protected void startArray(String name)

Called when an array is encountered in the JSON.

startObjectback to summary
protected void startObject(String name)

Called when an object is encountered in the JSON.

stopback to summary
public void stop()

Causes parsing to stop after the current or next object, array, or value.

stringback to summary
protected void string(String name, String value)

Called when a string or null value is encountered in the JSON.

unescapeback to summary
protected String unescape(String value)

Called to unescape string values. The default implementation does standard JSON unescaping.