Added in API level 11
JsonReader
public
final
class
JsonReader
extends Object
implements
Closeable
| java.lang.Object | |
| ↳ | android.util.JsonReader |
Reads a JSON (RFC 4627) encoded value as a stream of tokens. This stream includes both literal values (strings, numbers, booleans, and nulls) as well as the begin and end delimiters of objects and arrays. The tokens are traversed in depth-first order, the same order that they appear in the JSON document. Within JSON objects, name/value pairs are represented by a single token.
Parsing JSON
To create a recursive descent parser for your own JSON streams, first create an entry point method that creates aJsonReader.
Next, create handler methods for each structure in your JSON text. You'll need a method for each object type and for each array type.
- Within array handling methods, first call
beginArray()to consume the array's opening bracket. Then create a while loop that accumulates values, terminating whenhasNext()