945 lines
43 KiB
HTML
945 lines
43 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<!--NewPage-->
|
|
<HTML>
|
|
<HEAD>
|
|
<!-- Generated by javadoc (build 1.6.0_24) on Mon Jul 02 18:04:52 PDT 2012 -->
|
|
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<TITLE>
|
|
JsonReader (Gson 2.2.2 API)
|
|
</TITLE>
|
|
|
|
<META NAME="date" CONTENT="2012-07-02">
|
|
|
|
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">
|
|
|
|
<SCRIPT type="text/javascript">
|
|
function windowTitle()
|
|
{
|
|
if (location.href.indexOf('is-external=true') == -1) {
|
|
parent.document.title="JsonReader (Gson 2.2.2 API)";
|
|
}
|
|
}
|
|
</SCRIPT>
|
|
<NOSCRIPT>
|
|
</NOSCRIPT>
|
|
|
|
</HEAD>
|
|
|
|
<BODY BGCOLOR="white" onload="windowTitle();">
|
|
<HR>
|
|
|
|
|
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
|
<A NAME="navbar_top"><!-- --></A>
|
|
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
|
|
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
|
<TR>
|
|
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
|
<A NAME="navbar_top_firstrow"><!-- --></A>
|
|
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
|
<TR ALIGN="center" VALIGN="top">
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/JsonReader.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
|
</TR>
|
|
</TABLE>
|
|
</TD>
|
|
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
|
</EM>
|
|
</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
PREV CLASS
|
|
<A HREF="../../../../com/google/gson/stream/JsonToken.html" title="enum in com.google.gson.stream"><B>NEXT CLASS</B></A></FONT></TD>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../../../index.html?com/google/gson/stream/JsonReader.html" target="_top"><B>FRAMES</B></A>
|
|
<A HREF="JsonReader.html" target="_top"><B>NO FRAMES</B></A>
|
|
<SCRIPT type="text/javascript">
|
|
<!--
|
|
if(window==top) {
|
|
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
|
|
}
|
|
//-->
|
|
</SCRIPT>
|
|
<NOSCRIPT>
|
|
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
|
|
</NOSCRIPT>
|
|
|
|
|
|
</FONT></TD>
|
|
</TR>
|
|
<TR>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
|
</TR>
|
|
</TABLE>
|
|
<A NAME="skip-navbar_top"></A>
|
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
|
|
|
<HR>
|
|
<!-- ======== START OF CLASS DATA ======== -->
|
|
<H2>
|
|
<FONT SIZE="-1">
|
|
com.google.gson.stream</FONT>
|
|
<BR>
|
|
Class JsonReader</H2>
|
|
<PRE>
|
|
<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A>
|
|
<IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>com.google.gson.stream.JsonReader</B>
|
|
</PRE>
|
|
<DL>
|
|
<DT><B>All Implemented Interfaces:</B> <DD><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</A></DD>
|
|
</DL>
|
|
<HR>
|
|
<DL>
|
|
<DT><PRE>public class <B>JsonReader</B><DT>extends <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A><DT>implements <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</A></DL>
|
|
</PRE>
|
|
|
|
<P>
|
|
Reads a JSON (<a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>)
|
|
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.
|
|
|
|
<h3>Parsing JSON</h3>
|
|
To create a recursive descent parser for your own JSON streams, first create
|
|
an entry point method that creates a <code>JsonReader</code>.
|
|
|
|
<p>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.
|
|
<ul>
|
|
<li>Within <strong>array handling</strong> methods, first call <A HREF="../../../../com/google/gson/stream/JsonReader.html#beginArray()"><CODE>beginArray()</CODE></A> to consume the array's opening bracket. Then create a
|
|
while loop that accumulates values, terminating when <A HREF="../../../../com/google/gson/stream/JsonReader.html#hasNext()"><CODE>hasNext()</CODE></A>
|
|
is false. Finally, read the array's closing bracket by calling <A HREF="../../../../com/google/gson/stream/JsonReader.html#endArray()"><CODE>endArray()</CODE></A>.
|
|
<li>Within <strong>object handling</strong> methods, first call <A HREF="../../../../com/google/gson/stream/JsonReader.html#beginObject()"><CODE>beginObject()</CODE></A> to consume the object's opening brace. Then create a
|
|
while loop that assigns values to local variables based on their name.
|
|
This loop should terminate when <A HREF="../../../../com/google/gson/stream/JsonReader.html#hasNext()"><CODE>hasNext()</CODE></A> is false. Finally,
|
|
read the object's closing brace by calling <A HREF="../../../../com/google/gson/stream/JsonReader.html#endObject()"><CODE>endObject()</CODE></A>.
|
|
</ul>
|
|
<p>When a nested object or array is encountered, delegate to the
|
|
corresponding handler method.
|
|
|
|
<p>When an unknown name is encountered, strict parsers should fail with an
|
|
exception. Lenient parsers should call <A HREF="../../../../com/google/gson/stream/JsonReader.html#skipValue()"><CODE>skipValue()</CODE></A> to recursively
|
|
skip the value's nested tokens, which may otherwise conflict.
|
|
|
|
<p>If a value may be null, you should first check using <A HREF="../../../../com/google/gson/stream/JsonReader.html#peek()"><CODE>peek()</CODE></A>.
|
|
Null literals can be consumed using either <A HREF="../../../../com/google/gson/stream/JsonReader.html#nextNull()"><CODE>nextNull()</CODE></A> or <A HREF="../../../../com/google/gson/stream/JsonReader.html#skipValue()"><CODE>skipValue()</CODE></A>.
|
|
|
|
<h3>Example</h3>
|
|
Suppose we'd like to parse a stream of messages such as the following: <pre> <code>[
|
|
{
|
|
"id": 912345678901,
|
|
"text": "How do I read a JSON stream in Java?",
|
|
"geo": null,
|
|
"user": {
|
|
"name": "json_newb",
|
|
"followers_count": 41
|
|
}
|
|
},
|
|
{
|
|
"id": 912345678902,
|
|
"text": "@json_newb just use JsonReader!",
|
|
"geo": [50.454722, -104.606667],
|
|
"user": {
|
|
"name": "jesse",
|
|
"followers_count": 2
|
|
}
|
|
}
|
|
]</code></pre>
|
|
This code implements the parser for the above structure: <pre> <code>public List<Message> readJsonStream(InputStream in) throws IOException {
|
|
JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
|
|
try {
|
|
return readMessagesArray(reader);
|
|
} finally {
|
|
reader.close();
|
|
}
|
|
}
|
|
|
|
public List<Message> readMessagesArray(JsonReader reader) throws IOException {
|
|
List<Message> messages = new ArrayList<Message>();
|
|
|
|
reader.beginArray();
|
|
while (reader.hasNext()) {
|
|
messages.add(readMessage(reader));
|
|
}
|
|
reader.endArray();
|
|
return messages;
|
|
}
|
|
|
|
public Message readMessage(JsonReader reader) throws IOException {
|
|
long id = -1;
|
|
String text = null;
|
|
User user = null;
|
|
List<Double> geo = null;
|
|
|
|
reader.beginObject();
|
|
while (reader.hasNext()) {
|
|
String name = reader.nextName();
|
|
if (name.equals("id")) {
|
|
id = reader.nextLong();
|
|
} else if (name.equals("text")) {
|
|
text = reader.nextString();
|
|
} else if (name.equals("geo") && reader.peek() != JsonToken.NULL) {
|
|
geo = readDoublesArray(reader);
|
|
} else if (name.equals("user")) {
|
|
user = readUser(reader);
|
|
} else {
|
|
reader.skipValue();
|
|
}
|
|
}
|
|
reader.endObject();
|
|
return new Message(id, text, user, geo);
|
|
}
|
|
|
|
public List<Double> readDoublesArray(JsonReader reader) throws IOException {
|
|
List<Double> doubles = new ArrayList<Double>();
|
|
|
|
reader.beginArray();
|
|
while (reader.hasNext()) {
|
|
doubles.add(reader.nextDouble());
|
|
}
|
|
reader.endArray();
|
|
return doubles;
|
|
}
|
|
|
|
public User readUser(JsonReader reader) throws IOException {
|
|
String username = null;
|
|
int followersCount = -1;
|
|
|
|
reader.beginObject();
|
|
while (reader.hasNext()) {
|
|
String name = reader.nextName();
|
|
if (name.equals("name")) {
|
|
username = reader.nextString();
|
|
} else if (name.equals("followers_count")) {
|
|
followersCount = reader.nextInt();
|
|
} else {
|
|
reader.skipValue();
|
|
}
|
|
}
|
|
reader.endObject();
|
|
return new User(username, followersCount);
|
|
}</code></pre>
|
|
|
|
<h3>Number Handling</h3>
|
|
This reader permits numeric values to be read as strings and string values to
|
|
be read as numbers. For example, both elements of the JSON array <code>[1, "1"]</code> may be read using either <A HREF="../../../../com/google/gson/stream/JsonReader.html#nextInt()"><CODE>nextInt()</CODE></A> or <A HREF="../../../../com/google/gson/stream/JsonReader.html#nextString()"><CODE>nextString()</CODE></A>.
|
|
This behavior is intended to prevent lossy numeric conversions: double is
|
|
JavaScript's only numeric type and very large values like <code>9007199254740993</code> cannot be represented exactly on that platform. To minimize
|
|
precision loss, extremely large values should be written and read as strings
|
|
in JSON.
|
|
|
|
<a name="nonexecuteprefix"/><h3>Non-Execute Prefix</h3>
|
|
Web servers that serve private data using JSON may be vulnerable to <a
|
|
href="http://en.wikipedia.org/wiki/JSON#Cross-site_request_forgery">Cross-site
|
|
request forgery</a> attacks. In such an attack, a malicious site gains access
|
|
to a private JSON file by executing it with an HTML <code><script></code> tag.
|
|
|
|
<p>Prefixing JSON files with <code>")]}'\n"</code> makes them non-executable
|
|
by <code><script></code> tags, disarming the attack. Since the prefix is malformed
|
|
JSON, strict parsing fails when it is encountered. This class permits the
|
|
non-execute prefix when <A HREF="../../../../com/google/gson/stream/JsonReader.html#setLenient(boolean)"><CODE>lenient parsing</CODE></A> is
|
|
enabled.
|
|
|
|
<p>Each <code>JsonReader</code> may be used to read a single JSON stream. Instances
|
|
of this class are not thread safe.
|
|
<P>
|
|
|
|
<P>
|
|
<DL>
|
|
<DT><B>Since:</B></DT>
|
|
<DD>1.6</DD>
|
|
<DT><B>Author:</B></DT>
|
|
<DD>Jesse Wilson</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<P>
|
|
|
|
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
|
|
|
|
<A NAME="constructor_summary"><!-- --></A>
|
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
|
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
|
<B>Constructor Summary</B></FONT></TH>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#JsonReader(java.io.Reader)">JsonReader</A></B>(<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/Reader.html?is-external=true" title="class or interface in java.io">Reader</A> in)</CODE>
|
|
|
|
<BR>
|
|
Creates a new instance that reads a JSON-encoded stream from <code>in</code>.</TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<!-- ========== METHOD SUMMARY =========== -->
|
|
|
|
<A NAME="method_summary"><!-- --></A>
|
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
|
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
|
|
<B>Method Summary</B></FONT></TH>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> void</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#beginArray()">beginArray</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Consumes the next token from the JSON stream and asserts that it is the
|
|
beginning of a new array.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> void</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#beginObject()">beginObject</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Consumes the next token from the JSON stream and asserts that it is the
|
|
beginning of a new object.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> void</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#close()">close</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Closes this JSON reader and the underlying <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/Reader.html?is-external=true" title="class or interface in java.io"><CODE>Reader</CODE></A>.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> void</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#endArray()">endArray</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Consumes the next token from the JSON stream and asserts that it is the
|
|
end of the current array.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> void</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#endObject()">endObject</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Consumes the next token from the JSON stream and asserts that it is the
|
|
end of the current object.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> boolean</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#hasNext()">hasNext</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns true if the current array or object has another element.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> boolean</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#isLenient()">isLenient</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns true if this parser is liberal in what it accepts.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> boolean</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#nextBoolean()">nextBoolean</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#BOOLEAN"><CODE>boolean</CODE></A> value of the next token,
|
|
consuming it.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> double</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#nextDouble()">nextDouble</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#NUMBER"><CODE>double</CODE></A> value of the next token,
|
|
consuming it.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> int</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#nextInt()">nextInt</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#NUMBER"><CODE>int</CODE></A> value of the next token,
|
|
consuming it.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> long</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#nextLong()">nextLong</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#NUMBER"><CODE>long</CODE></A> value of the next token,
|
|
consuming it.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#nextName()">nextName</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the next token, a <A HREF="../../../../com/google/gson/stream/JsonToken.html#NAME"><CODE>property name</CODE></A>, and
|
|
consumes it.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> void</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#nextNull()">nextNull</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Consumes the next token from the JSON stream and asserts that it is a
|
|
literal null.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#nextString()">nextString</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#STRING"><CODE>string</CODE></A> value of the next token,
|
|
consuming it.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> <A HREF="../../../../com/google/gson/stream/JsonToken.html" title="enum in com.google.gson.stream">JsonToken</A></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#peek()">peek</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Returns the type of the next token without consuming it.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> void</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#setLenient(boolean)">setLenient</A></B>(boolean lenient)</CODE>
|
|
|
|
<BR>
|
|
Configure this parser to be be liberal in what it accepts.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> void</CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#skipValue()">skipValue</A></B>()</CODE>
|
|
|
|
<BR>
|
|
Skips the next value recursively.</TD>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
|
|
<CODE> <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD>
|
|
<TD><CODE><B><A HREF="../../../../com/google/gson/stream/JsonReader.html#toString()">toString</A></B>()</CODE>
|
|
|
|
<BR>
|
|
</TD>
|
|
</TR>
|
|
</TABLE>
|
|
<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
|
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
|
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
|
|
<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH>
|
|
</TR>
|
|
<TR BGCOLOR="white" CLASS="TableRowColor">
|
|
<TD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<P>
|
|
|
|
<!-- ========= CONSTRUCTOR DETAIL ======== -->
|
|
|
|
<A NAME="constructor_detail"><!-- --></A>
|
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
|
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
|
|
<B>Constructor Detail</B></FONT></TH>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<A NAME="JsonReader(java.io.Reader)"><!-- --></A><H3>
|
|
JsonReader</H3>
|
|
<PRE>
|
|
public <B>JsonReader</B>(<A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/Reader.html?is-external=true" title="class or interface in java.io">Reader</A> in)</PRE>
|
|
<DL>
|
|
<DD>Creates a new instance that reads a JSON-encoded stream from <code>in</code>.
|
|
<P>
|
|
</DL>
|
|
|
|
<!-- ============ METHOD DETAIL ========== -->
|
|
|
|
<A NAME="method_detail"><!-- --></A>
|
|
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
|
|
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
|
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
|
|
<B>Method Detail</B></FONT></TH>
|
|
</TR>
|
|
</TABLE>
|
|
|
|
<A NAME="setLenient(boolean)"><!-- --></A><H3>
|
|
setLenient</H3>
|
|
<PRE>
|
|
public final void <B>setLenient</B>(boolean lenient)</PRE>
|
|
<DL>
|
|
<DD>Configure this parser to be be liberal in what it accepts. By default,
|
|
this parser is strict and only accepts JSON as specified by <a
|
|
href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>. Setting the
|
|
parser to lenient causes it to ignore the following syntax errors:
|
|
|
|
<ul>
|
|
<li>Streams that start with the <a href="#nonexecuteprefix">non-execute
|
|
prefix</a>, <code>")]}'\n"</code>.
|
|
<li>Streams that include multiple top-level values. With strict parsing,
|
|
each stream must contain exactly one top-level value.
|
|
<li>Top-level values of any type. With strict parsing, the top-level
|
|
value must be an object or an array.
|
|
<li>Numbers may be <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Double.html?is-external=true#isNaN()" title="class or interface in java.lang"><CODE>NaNs</CODE></A> or <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Double.html?is-external=true#isInfinite()" title="class or interface in java.lang"><CODE>infinities</CODE></A>.
|
|
<li>End of line comments starting with <code>//</code> or <code>#</code> and
|
|
ending with a newline character.
|
|
<li>C-style comments starting with <code>/*</code> and ending with
|
|
<code>*</code><code>/</code>. Such comments may not be nested.
|
|
<li>Names that are unquoted or <code>'single quoted'</code>.
|
|
<li>Strings that are unquoted or <code>'single quoted'</code>.
|
|
<li>Array elements separated by <code>;</code> instead of <code>,</code>.
|
|
<li>Unnecessary array separators. These are interpreted as if null
|
|
was the omitted value.
|
|
<li>Names and values separated by <code>=</code> or <code>=></code> instead of
|
|
<code>:</code>.
|
|
<li>Name/value pairs separated by <code>;</code> instead of <code>,</code>.
|
|
</ul>
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="isLenient()"><!-- --></A><H3>
|
|
isLenient</H3>
|
|
<PRE>
|
|
public final boolean <B>isLenient</B>()</PRE>
|
|
<DL>
|
|
<DD>Returns true if this parser is liberal in what it accepts.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="beginArray()"><!-- --></A><H3>
|
|
beginArray</H3>
|
|
<PRE>
|
|
public void <B>beginArray</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Consumes the next token from the JSON stream and asserts that it is the
|
|
beginning of a new array.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="endArray()"><!-- --></A><H3>
|
|
endArray</H3>
|
|
<PRE>
|
|
public void <B>endArray</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Consumes the next token from the JSON stream and asserts that it is the
|
|
end of the current array.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="beginObject()"><!-- --></A><H3>
|
|
beginObject</H3>
|
|
<PRE>
|
|
public void <B>beginObject</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Consumes the next token from the JSON stream and asserts that it is the
|
|
beginning of a new object.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="endObject()"><!-- --></A><H3>
|
|
endObject</H3>
|
|
<PRE>
|
|
public void <B>endObject</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Consumes the next token from the JSON stream and asserts that it is the
|
|
end of the current object.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="hasNext()"><!-- --></A><H3>
|
|
hasNext</H3>
|
|
<PRE>
|
|
public boolean <B>hasNext</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Returns true if the current array or object has another element.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="peek()"><!-- --></A><H3>
|
|
peek</H3>
|
|
<PRE>
|
|
public <A HREF="../../../../com/google/gson/stream/JsonToken.html" title="enum in com.google.gson.stream">JsonToken</A> <B>peek</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Returns the type of the next token without consuming it.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="nextName()"><!-- --></A><H3>
|
|
nextName</H3>
|
|
<PRE>
|
|
public <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>nextName</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Returns the next token, a <A HREF="../../../../com/google/gson/stream/JsonToken.html#NAME"><CODE>property name</CODE></A>, and
|
|
consumes it.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE> - if the next token in the stream is not a property
|
|
name.</DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="nextString()"><!-- --></A><H3>
|
|
nextString</H3>
|
|
<PRE>
|
|
public <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>nextString</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#STRING"><CODE>string</CODE></A> value of the next token,
|
|
consuming it. If the next token is a number, this method will return its
|
|
string form.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the next token is not a string or if
|
|
this reader is closed.
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="nextBoolean()"><!-- --></A><H3>
|
|
nextBoolean</H3>
|
|
<PRE>
|
|
public boolean <B>nextBoolean</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#BOOLEAN"><CODE>boolean</CODE></A> value of the next token,
|
|
consuming it.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the next token is not a boolean or if
|
|
this reader is closed.
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="nextNull()"><!-- --></A><H3>
|
|
nextNull</H3>
|
|
<PRE>
|
|
public void <B>nextNull</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Consumes the next token from the JSON stream and asserts that it is a
|
|
literal null.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the next token is not null or if this
|
|
reader is closed.
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="nextDouble()"><!-- --></A><H3>
|
|
nextDouble</H3>
|
|
<PRE>
|
|
public double <B>nextDouble</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#NUMBER"><CODE>double</CODE></A> value of the next token,
|
|
consuming it. If the next token is a string, this method will attempt to
|
|
parse it as a double using <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Double.html?is-external=true#parseDouble(java.lang.String)" title="class or interface in java.lang"><CODE>Double.parseDouble(String)</CODE></A>.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the next token is not a literal value.
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/NumberFormatException.html?is-external=true" title="class or interface in java.lang">NumberFormatException</A></CODE> - if the next literal value cannot be parsed
|
|
as a double, or is non-finite.
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="nextLong()"><!-- --></A><H3>
|
|
nextLong</H3>
|
|
<PRE>
|
|
public long <B>nextLong</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#NUMBER"><CODE>long</CODE></A> value of the next token,
|
|
consuming it. If the next token is a string, this method will attempt to
|
|
parse it as a long. If the next token's numeric value cannot be exactly
|
|
represented by a Java <code>long</code>, this method throws.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the next token is not a literal value.
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/NumberFormatException.html?is-external=true" title="class or interface in java.lang">NumberFormatException</A></CODE> - if the next literal value cannot be parsed
|
|
as a number, or exactly represented as a long.
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="nextInt()"><!-- --></A><H3>
|
|
nextInt</H3>
|
|
<PRE>
|
|
public int <B>nextInt</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Returns the <A HREF="../../../../com/google/gson/stream/JsonToken.html#NUMBER"><CODE>int</CODE></A> value of the next token,
|
|
consuming it. If the next token is a string, this method will attempt to
|
|
parse it as an int. If the next token's numeric value cannot be exactly
|
|
represented by a Java <code>int</code>, this method throws.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the next token is not a literal value.
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/NumberFormatException.html?is-external=true" title="class or interface in java.lang">NumberFormatException</A></CODE> - if the next literal value cannot be parsed
|
|
as a number, or exactly represented as an int.
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="close()"><!-- --></A><H3>
|
|
close</H3>
|
|
<PRE>
|
|
public void <B>close</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Closes this JSON reader and the underlying <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/Reader.html?is-external=true" title="class or interface in java.io"><CODE>Reader</CODE></A>.
|
|
<P>
|
|
<DD><DL>
|
|
<DT><B>Specified by:</B><DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/Closeable.html?is-external=true#close()" title="class or interface in java.io">close</A></CODE> in interface <CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</A></CODE></DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="skipValue()"><!-- --></A><H3>
|
|
skipValue</H3>
|
|
<PRE>
|
|
public void <B>skipValue</B>()
|
|
throws <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE>
|
|
<DL>
|
|
<DD>Skips the next value recursively. If it is an object or array, all nested
|
|
elements are skipped. This method is intended for use when the JSON token
|
|
stream contains unrecognized or unhandled values.
|
|
<P>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
<DD><DL>
|
|
|
|
<DT><B>Throws:</B>
|
|
<DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL>
|
|
</DD>
|
|
</DL>
|
|
<HR>
|
|
|
|
<A NAME="toString()"><!-- --></A><H3>
|
|
toString</H3>
|
|
<PRE>
|
|
public <A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>toString</B>()</PRE>
|
|
<DL>
|
|
<DD><DL>
|
|
<DT><B>Overrides:</B><DD><CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A></CODE> in class <CODE><A HREF="http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></CODE></DL>
|
|
</DD>
|
|
<DD><DL>
|
|
</DL>
|
|
</DD>
|
|
</DL>
|
|
<!-- ========= END OF CLASS DATA ========= -->
|
|
<HR>
|
|
|
|
|
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
|
<A NAME="navbar_bottom"><!-- --></A>
|
|
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
|
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
|
<TR>
|
|
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
|
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
|
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
|
<TR ALIGN="center" VALIGN="top">
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/JsonReader.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
|
|
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
|
|
</TR>
|
|
</TABLE>
|
|
</TD>
|
|
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
|
</EM>
|
|
</TD>
|
|
</TR>
|
|
|
|
<TR>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
PREV CLASS
|
|
<A HREF="../../../../com/google/gson/stream/JsonToken.html" title="enum in com.google.gson.stream"><B>NEXT CLASS</B></A></FONT></TD>
|
|
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
|
|
<A HREF="../../../../index.html?com/google/gson/stream/JsonReader.html" target="_top"><B>FRAMES</B></A>
|
|
<A HREF="JsonReader.html" target="_top"><B>NO FRAMES</B></A>
|
|
<SCRIPT type="text/javascript">
|
|
<!--
|
|
if(window==top) {
|
|
document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
|
|
}
|
|
//-->
|
|
</SCRIPT>
|
|
<NOSCRIPT>
|
|
<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
|
|
</NOSCRIPT>
|
|
|
|
|
|
</FONT></TD>
|
|
</TR>
|
|
<TR>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
|
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
|
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
|
</TR>
|
|
</TABLE>
|
|
<A NAME="skip-navbar_bottom"></A>
|
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
|
|
|
<HR>
|
|
Copyright © 2008-2012 <a href="http://www.google.com">Google, Inc.</a>. All Rights Reserved.
|
|
</BODY>
|
|
</HTML>
|