Fix JsonWriter documentation regarding top-level value (#1766)
* Fix JsonReader / JsonWriter documentation regarding top-level value RFC 7159 allows any top-level value (not only arrays or objects) [0], however when #773 added this functionality it appears the author forgot to update the documentation of these classes. [0] https://tools.ietf.org/html/rfc7159#appendix-A > Changed the definition of "JSON text" so that it can be any JSON > value, removing the constraint that it be an object or array. * Fix missing space
This commit is contained in:
parent
9eb04414c0
commit
f7cefcb426
|
@ -42,10 +42,9 @@ import static com.google.gson.stream.JsonScope.NONEMPTY_OBJECT;
|
||||||
* and end delimiters of objects and arrays.
|
* and end delimiters of objects and arrays.
|
||||||
*
|
*
|
||||||
* <h3>Encoding JSON</h3>
|
* <h3>Encoding JSON</h3>
|
||||||
* To encode your data as JSON, create a new {@code JsonWriter}. Each JSON
|
* To encode your data as JSON, create a new {@code JsonWriter}. Call methods
|
||||||
* document must contain one top-level array or object. Call methods on the
|
* on the writer as you walk the structure's contents, nesting arrays and objects
|
||||||
* writer as you walk the structure's contents, nesting arrays and objects as
|
* as necessary:
|
||||||
* necessary:
|
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>To write <strong>arrays</strong>, first call {@link #beginArray()}.
|
* <li>To write <strong>arrays</strong>, first call {@link #beginArray()}.
|
||||||
* Write each of the array's elements with the appropriate {@link #value}
|
* Write each of the array's elements with the appropriate {@link #value}
|
||||||
|
@ -170,7 +169,7 @@ public class JsonWriter implements Closeable, Flushable {
|
||||||
HTML_SAFE_REPLACEMENT_CHARS['\''] = "\\u0027";
|
HTML_SAFE_REPLACEMENT_CHARS['\''] = "\\u0027";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The output data, containing at most one top-level array or object. */
|
/** The JSON output destination */
|
||||||
private final Writer out;
|
private final Writer out;
|
||||||
|
|
||||||
private int[] stack = new int[32];
|
private int[] stack = new int[32];
|
||||||
|
@ -234,8 +233,6 @@ public class JsonWriter implements Closeable, Flushable {
|
||||||
* href="http://www.ietf.org/rfc/rfc7159.txt">RFC 7159</a>. Setting the writer
|
* href="http://www.ietf.org/rfc/rfc7159.txt">RFC 7159</a>. Setting the writer
|
||||||
* to lenient permits the following:
|
* to lenient permits the following:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Top-level values of any type. With strict writing, the top-level
|
|
||||||
* value must be an object or an array.
|
|
||||||
* <li>Numbers may be {@link Double#isNaN() NaNs} or {@link
|
* <li>Numbers may be {@link Double#isNaN() NaNs} or {@link
|
||||||
* Double#isInfinite() infinities}.
|
* Double#isInfinite() infinities}.
|
||||||
* </ul>
|
* </ul>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user