Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update javadoc according to issue #356. #357

Merged
merged 1 commit into from
Jul 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 39 additions & 9 deletions JSONArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ public Object optQuery(String jsonPointer) {
* Queries and returns a value from this object using {@code jsonPointer}, or
* returns null if the query fails due to a missing key.
*
* @param The JSON pointer
* @param jsonPointer The JSON pointer
* @return the queried value or {@code null}
* @throws IllegalArgumentException if {@code jsonPointer} has invalid syntax
*/
Expand Down Expand Up @@ -1323,8 +1323,9 @@ public JSONObject toJSONObject(JSONArray names) throws JSONException {
* whitespace is added. If it is not possible to produce a syntactically
* correct JSON text then null will be returned instead. This could occur if
* the array contains an invalid number.
* <p>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
* </b>
*
* @return a printable, displayable, transmittable representation of the
* array.
Expand All @@ -1339,9 +1340,24 @@ public String toString() {
}

/**
* Make a pretty-printed JSON text of this JSONArray. Warning: This method
* assumes that the data structure is acyclical.
*
* Make a pretty-printed JSON text of this JSONArray.
*
* <p>If <code>indentFactor > 0</code> and the {@link JSONArray} has only
* one element, then the array will be output on a single line:
* <pre>{@code [1]}</pre>
*
* <p>If an array has 2 or more elements, then it will be output across
* multiple lines: <pre>{@code
* [
* 1,
* "value 2",
* 3
* ]
* }</pre>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
* </b>
*
* @param indentFactor
* The number of spaces to add to each level of indentation.
* @return a printable, displayable, transmittable representation of the
Expand All @@ -1360,8 +1376,9 @@ public String toString(int indentFactor) throws JSONException {
/**
* Write the contents of the JSONArray as JSON text to a writer. For
* compactness, no whitespace is added.
* <p>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
*</b>
*
* @return The writer.
* @throws JSONException
Expand All @@ -1371,10 +1388,23 @@ public Writer write(Writer writer) throws JSONException {
}

/**
* Write the contents of the JSONArray as JSON text to a writer. For
* compactness, no whitespace is added.
* <p>
* Write the contents of the JSONArray as JSON text to a writer.
*
* <p>If <code>indentFactor > 0</code> and the {@link JSONArray} has only
* one element, then the array will be output on a single line:
* <pre>{@code [1]}</pre>
*
* <p>If an array has 2 or more elements, then it will be output across
* multiple lines: <pre>{@code
* [
* 1,
* "value 2",
* 3
* ]
* }</pre>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
* </b>
*
* @param writer
* Writes the serialized JSON
Expand Down
40 changes: 33 additions & 7 deletions JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ public Object optQuery(String jsonPointer) {
* Queries and returns a value from this object using {@code jsonPointer}, or
* returns null if the query fails due to a missing key.
*
* @param The JSON pointer
* @param jsonPointer The JSON pointer
* @return the queried value or {@code null}
* @throws IllegalArgumentException if {@code jsonPointer} has invalid syntax
*/
Expand Down Expand Up @@ -2002,9 +2002,10 @@ public JSONArray toJSONArray(JSONArray names) throws JSONException {
* Make a JSON text of this JSONObject. For compactness, no whitespace is
* added. If this would not result in a syntactically correct JSON text,
* then null will be returned instead.
* <p>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
*
* </b>
*
* @return a printable, displayable, portable, transmittable representation
* of the object, beginning with <code>{</code>&nbsp;<small>(left
* brace)</small> and ending with <code>}</code>&nbsp;<small>(right
Expand All @@ -2021,8 +2022,20 @@ public String toString() {

/**
* Make a pretty-printed JSON text of this JSONObject.
* <p>
*
* <p>If <code>indentFactor > 0</code> and the {@link JSONObject}
* has only one key, then the object will be output on a single line:
* <pre>{@code {"key": 1}}</pre>
*
* <p>If an object has 2 or more keys, then it will be output across
* multiple lines: <code><pre>{
* "key1": 1,
* "key2": "value 2",
* "key3": 3
* }</pre></code>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
* </b>
*
* @param indentFactor
* The number of spaces to add to each level of indentation.
Expand Down Expand Up @@ -2172,9 +2185,10 @@ public static Object wrap(Object object) {
/**
* Write the contents of the JSONObject as JSON text to a writer. For
* compactness, no whitespace is added.
* <p>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
*
* </b>
*
* @return The writer.
* @throws JSONException
*/
Expand Down Expand Up @@ -2238,8 +2252,20 @@ static final void indent(Writer writer, int indent) throws IOException {

/**
* Write the contents of the JSONObject as JSON text to a writer.
* <p>
*
* <p>If <code>indentFactor > 0</code> and the {@link JSONObject}
* has only one key, then the object will be output on a single line:
* <pre>{@code {"key": 1}}</pre>
*
* <p>If an object has 2 or more keys, then it will be output across
* multiple lines: <code><pre>{
* "key1": 1,
* "key2": "value 2",
* "key3": 3
* }</pre></code>
* <p><b>
* Warning: This method assumes that the data structure is acyclical.
* </b>
*
* @param writer
* Writes the serialized JSON
Expand Down