diff --git a/src/main/java/org/json/CDL.java b/src/main/java/org/json/CDL.java index 6bc41dc..f12cfc0 100644 --- a/src/main/java/org/json/CDL.java +++ b/src/main/java/org/json/CDL.java @@ -98,7 +98,7 @@ public class CDL { * Produce a JSONArray of strings from a row of comma delimited values. * @param x A JSONTokener of the source text. * @return A JSONArray of strings. - * @throws JSONException + * @throws JSONException if a called function fails */ public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException { JSONArray ja = new JSONArray(); @@ -134,7 +134,7 @@ public class CDL { * method. * @param x A JSONTokener of the source text. * @return A JSONObject combining the names and values. - * @throws JSONException + * @throws JSONException if a called function fails */ public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) throws JSONException { @@ -184,7 +184,7 @@ public class CDL { * using the first row as a source of names. * @param string The comma delimited text. * @return A JSONArray of JSONObjects. - * @throws JSONException + * @throws JSONException if a called function fails */ public static JSONArray toJSONArray(String string) throws JSONException { return toJSONArray(new JSONTokener(string)); @@ -195,7 +195,7 @@ public class CDL { * using the first row as a source of names. * @param x The JSONTokener containing the comma delimited text. * @return A JSONArray of JSONObjects. - * @throws JSONException + * @throws JSONException if a called function fails */ public static JSONArray toJSONArray(JSONTokener x) throws JSONException { return toJSONArray(rowToJSONArray(x), x); @@ -207,7 +207,7 @@ public class CDL { * @param names A JSONArray of strings. * @param string The comma delimited text. * @return A JSONArray of JSONObjects. - * @throws JSONException + * @throws JSONException if a called function fails */ public static JSONArray toJSONArray(JSONArray names, String string) throws JSONException { @@ -220,7 +220,7 @@ public class CDL { * @param names A JSONArray of strings. * @param x A JSONTokener of the source text. * @return A JSONArray of JSONObjects. - * @throws JSONException + * @throws JSONException if a called function fails */ public static JSONArray toJSONArray(JSONArray names, JSONTokener x) throws JSONException { @@ -248,7 +248,7 @@ public class CDL { * JSONObject. * @param ja A JSONArray of JSONObjects. * @return A comma delimited text. - * @throws JSONException + * @throws JSONException if a called function fails */ public static String toString(JSONArray ja) throws JSONException { JSONObject jo = ja.optJSONObject(0); @@ -268,7 +268,7 @@ public class CDL { * @param names A JSONArray of strings. * @param ja A JSONArray of JSONObjects. * @return A comma delimited text. - * @throws JSONException + * @throws JSONException if a called function fails */ public static String toString(JSONArray names, JSONArray ja) throws JSONException { diff --git a/src/main/java/org/json/Cookie.java b/src/main/java/org/json/Cookie.java index 348dc68..5da423a 100644 --- a/src/main/java/org/json/Cookie.java +++ b/src/main/java/org/json/Cookie.java @@ -76,7 +76,7 @@ public class Cookie { * @param string The cookie specification string. * @return A JSONObject containing "name", "value", and possibly other * members. - * @throws JSONException + * @throws JSONException if a called function fails or a syntax error */ public static JSONObject toJSONObject(String string) throws JSONException { String name; @@ -113,7 +113,7 @@ public class Cookie { * All other members are ignored. * @param jo A JSONObject * @return A cookie specification string - * @throws JSONException + * @throws JSONException if a called function fails */ public static String toString(JSONObject jo) throws JSONException { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/org/json/CookieList.java b/src/main/java/org/json/CookieList.java index c67ee3a..83b2630 100644 --- a/src/main/java/org/json/CookieList.java +++ b/src/main/java/org/json/CookieList.java @@ -42,7 +42,7 @@ public class CookieList { * cookieJSONObject.getString("value")); * @param string A cookie list string * @return A JSONObject - * @throws JSONException + * @throws JSONException if a called function fails */ public static JSONObject toJSONObject(String string) throws JSONException { JSONObject jo = new JSONObject(); @@ -63,7 +63,7 @@ public class CookieList { * in the names and values are replaced by "%hh". * @param jo A JSONObject * @return A cookie list string - * @throws JSONException + * @throws JSONException if a called function fails */ public static String toString(JSONObject jo) throws JSONException { boolean b = false; diff --git a/src/main/java/org/json/HTTP.java b/src/main/java/org/json/HTTP.java index 84ed53b..cc01167 100644 --- a/src/main/java/org/json/HTTP.java +++ b/src/main/java/org/json/HTTP.java @@ -51,12 +51,12 @@ public class HTTP { * "Reason-Phrase": "OK" (for example) * } * In addition, the other parameters in the header will be captured, using - * the HTTP field names as JSON names, so that
+ * the HTTP field names as JSON names, so that* become - *{@code * Date: Sun, 26 May 2002 18:06:04 GMT * Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s - * Cache-Control: no-cache+ * Cache-Control: no-cache}
{... + **{@code * Date: "Sun, 26 May 2002 18:06:04 GMT", * Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s", * "Cache-Control": "no-cache", @@ -66,7 +66,7 @@ public class HTTP { * @param string An HTTP header string. * @return A JSONObject containing the elements and attributes * of the XML string. - * @throws JSONException + * @throws JSONException if a called function fails */ public static JSONObject toJSONObject(String string) throws JSONException { JSONObject jo = new JSONObject(); diff --git a/src/main/java/org/json/HTTPTokener.java b/src/main/java/org/json/HTTPTokener.java index 55f48ff..16c7081 100644 --- a/src/main/java/org/json/HTTPTokener.java +++ b/src/main/java/org/json/HTTPTokener.java @@ -43,8 +43,8 @@ public class HTTPTokener extends JSONTokener { /** * Get the next token or string. This is used in parsing HTTP headers. - * @throws JSONException * @return A String. + * @throws JSONException if a syntax error occurs */ public String nextToken() throws JSONException { char c; diff --git a/src/main/java/org/json/JSONArray.java b/src/main/java/org/json/JSONArray.java index 8847c5d..d5ad7f4 100644 --- a/src/main/java/org/json/JSONArray.java +++ b/src/main/java/org/json/JSONArray.java @@ -1333,7 +1333,7 @@ public class JSONArray implements Iterable** Warning: This method assumes that the data structure is acyclical. * @@ -2409,9 +2409,9 @@ public class JSONObject { *
* Warning: This method assumes that the data structure is acyclical. * - * + * @param writer the writer object * @return The writer. - * @throws JSONException + * @throws JSONException if a called function has an error */ public Writer write(Writer writer) throws JSONException { return this.write(writer, 0, 0); @@ -2470,16 +2470,16 @@ public class JSONObject { /** * Write the contents of the JSONObject as JSON text to a writer. * - *
If
indentFactor > 0
and the {@link JSONObject} + *If
{@code indentFactor > 0}and the {@link JSONObject} * has only one key, then the object will be output on a single line: *{@code {"key": 1}}* *If an object has 2 or more keys, then it will be output across - * multiple lines:
+ * }}
{ + * multiple lines:{@code { * "key1": 1, * "key2": "value 2", * "key3": 3 - * }
* Warning: This method assumes that the data structure is acyclical.
*
@@ -2491,7 +2491,8 @@ public class JSONObject {
* @param indent
* The indentation of the top level.
* @return The writer.
- * @throws JSONException
+ * @throws JSONException if a called function has an error or a write error
+ * occurs
*/
public Writer write(Writer writer, int indentFactor, int indent)
throws JSONException {
diff --git a/src/main/java/org/json/JSONPointer.java b/src/main/java/org/json/JSONPointer.java
index d122fd8..e8a0b78 100644
--- a/src/main/java/org/json/JSONPointer.java
+++ b/src/main/java/org/json/JSONPointer.java
@@ -68,6 +68,7 @@ public class JSONPointer {
/**
* Creates a {@code JSONPointer} instance using the tokens previously set using the
* {@link #append(String)} method calls.
+ * @return a JSONPointer object
*/
public JSONPointer build() {
return new JSONPointer(this.refTokens);
@@ -277,6 +278,7 @@ public class JSONPointer {
/**
* Returns a string representing the JSONPointer path value using URI
* fragment identifier representation
+ * @return a uri fragment string
*/
public String toURIFragment() {
try {
diff --git a/src/main/java/org/json/JSONWriter.java b/src/main/java/org/json/JSONWriter.java
index b61a6f1..dafb1b2 100644
--- a/src/main/java/org/json/JSONWriter.java
+++ b/src/main/java/org/json/JSONWriter.java
@@ -93,6 +93,7 @@ public class JSONWriter {
/**
* Make a fresh JSONWriter. It can be used to build one JSON text.
+ * @param w an appendable object
*/
public JSONWriter(Appendable w) {
this.comma = false;
@@ -373,7 +374,7 @@ public class JSONWriter {
* false
.
* @param b A boolean.
* @return this
- * @throws JSONException
+ * @throws JSONException if a called function has an error
*/
public JSONWriter value(boolean b) throws JSONException {
return this.append(b ? "true" : "false");
@@ -393,7 +394,7 @@ public class JSONWriter {
* Append a long value.
* @param l A long.
* @return this
- * @throws JSONException
+ * @throws JSONException if a called function has an error
*/
public JSONWriter value(long l) throws JSONException {
return this.append(Long.toString(l));
diff --git a/src/main/java/org/json/Property.java b/src/main/java/org/json/Property.java
index ff33a04..7caeebb 100644
--- a/src/main/java/org/json/Property.java
+++ b/src/main/java/org/json/Property.java
@@ -37,7 +37,7 @@ public class Property {
* Converts a property file object into a JSONObject. The property file object is a table of name value pairs.
* @param properties java.util.Properties
* @return JSONObject
- * @throws JSONException
+ * @throws JSONException if a called function has an error
*/
public static JSONObject toJSONObject(java.util.Properties properties) throws JSONException {
// can't use the new constructor for Android support
@@ -57,7 +57,7 @@ public class Property {
* Converts the JSONObject into a property file object.
* @param jo JSONObject
* @return java.util.Properties
- * @throws JSONException
+ * @throws JSONException if a called function has an error
*/
public static Properties toProperties(JSONObject jo) throws JSONException {
Properties properties = new Properties();
diff --git a/src/main/java/org/json/XML.java b/src/main/java/org/json/XML.java
index f506f67..fb44cc9 100644
--- a/src/main/java/org/json/XML.java
+++ b/src/main/java/org/json/XML.java
@@ -50,7 +50,7 @@ public class XML {
/** The Character '='. */
public static final Character EQ = '=';
- /** The Character '>'. */
+ /** The Character
{@code '>'. }*/ public static final Character GT = '>'; /** The Character '<'. */ @@ -113,13 +113,13 @@ public class XML { /** * Replace special characters with XML escapes: * - *
- * & (ampersand) is replaced by & - * < (less than) is replaced by < - * > (greater than) is replaced by > - * " (double quote) is replaced by " - * ' (single quote / apostrophe) is replaced by ' - *+ *
{@code + * & (ampersand) is replaced by & + * < (less than) is replaced by < + * > (greater than) is replaced by > + * " (double quote) is replaced by " + * ' (single quote / apostrophe) is replaced by ' + * }* * @param string * The string to be escaped. @@ -477,7 +477,8 @@ public class XML { * name/value pairs and arrays of values. JSON does not does not like to * distinguish between elements and attributes. Sequences of similar * elements are represented as JSONArrays. Content text may be placed in a - * "content" member. Comments, prologs, DTDs, and
<[ [ ]]>
+ * "content" member. Comments, prologs, DTDs, and {@code + * <[ [ ]]>}* are ignored. * * @param string @@ -497,7 +498,8 @@ public class XML { * name/value pairs and arrays of values. JSON does not does not like to * distinguish between elements and attributes. Sequences of similar * elements are represented as JSONArrays. Content text may be placed in a - * "content" member. Comments, prologs, DTDs, and
<[ [ ]]>
+ * "content" member. Comments, prologs, DTDs, and {@code + * <[ [ ]]>}* are ignored. * * @param reader The XML source reader. @@ -516,7 +518,8 @@ public class XML { * name/value pairs and arrays of values. JSON does not does not like to * distinguish between elements and attributes. Sequences of similar * elements are represented as JSONArrays. Content text may be placed in a - * "content" member. Comments, prologs, DTDs, and
<[ [ ]]>
+ * "content" member. Comments, prologs, DTDs, and {@code + * <[ [ ]]>}* are ignored. * * All values are converted as strings, for 1, 01, 29.0 will not be coerced to @@ -543,7 +546,8 @@ public class XML { * name/value pairs and arrays of values. JSON does not does not like to * distinguish between elements and attributes. Sequences of similar * elements are represented as JSONArrays. Content text may be placed in a - * "content" member. Comments, prologs, DTDs, and
<[ [ ]]>
+ * "content" member. Comments, prologs, DTDs, and {@code + * <[ [ ]]>}* are ignored. * * All values are converted as strings, for 1, 01, 29.0 will not be coerced to @@ -574,7 +578,8 @@ public class XML { * name/value pairs and arrays of values. JSON does not does not like to * distinguish between elements and attributes. Sequences of similar * elements are represented as JSONArrays. Content text may be placed in a - * "content" member. Comments, prologs, DTDs, and
<[ [ ]]>
+ * "content" member. Comments, prologs, DTDs, and {@code + * <[ [ ]]>}* are ignored. * * All values are converted as strings, for 1, 01, 29.0 will not be coerced to @@ -599,7 +604,8 @@ public class XML { * name/value pairs and arrays of values. JSON does not does not like to * distinguish between elements and attributes. Sequences of similar * elements are represented as JSONArrays. Content text may be placed in a - * "content" member. Comments, prologs, DTDs, and
<[ [ ]]>
+ * "content" member. Comments, prologs, DTDs, and {@code + * <[ [ ]]>}* are ignored. * * All values are converted as strings, for 1, 01, 29.0 will not be coerced to diff --git a/src/main/java/org/json/XMLTokener.java b/src/main/java/org/json/XMLTokener.java index a9d20b7..0ecdb4f 100644 --- a/src/main/java/org/json/XMLTokener.java +++ b/src/main/java/org/json/XMLTokener.java @@ -90,12 +90,13 @@ public class XMLTokener extends JSONTokener { /** * Get the next XML outer token, trimming whitespace. There are two kinds - * of tokens: the '<' character which begins a markup tag, and the content + * of tokens: the
{@code '<' }character which begins a markup + * tag, and the content * text between markup tags. * - * @return A string, or a '<' Character, or null if there is no more - * source text. - * @throws JSONException + * @return A string, or a
{@code '<' }Character, or null if + * there is no more source text. + * @throws JSONException if a called function has an error */ public Object nextContent() throws JSONException { char c; @@ -129,8 +130,10 @@ public class XMLTokener extends JSONTokener { /** + *
{@code
* Return the next entity. These entities are translated to Characters:
- * & ' > < "
.
+ * & ' > < ".
+ * }
* @param ampersand An ampersand character.
* @return A Character or an entity String if the entity is not recognized.
* @throws JSONException If missing ';' in XML entity.
@@ -183,11 +186,14 @@ public class XMLTokener extends JSONTokener {
/**
+ * {@code
* Returns the next XML meta token. This is used for skipping over
* and ...?> structures.
- * @return Syntax characters (< > / = ! ?
) are returned as
+ * }
+ * @return {@code Syntax characters (< > / = ! ?) are returned as * Character, and strings and names are returned as Boolean. We don't care * what the values actually are. + * }* @throws JSONException If a string is not properly closed or if the XML * is badly structured. */ @@ -250,10 +256,12 @@ public class XMLTokener extends JSONTokener { /** + *
{@code
* Get the next XML Token. These tokens are found inside of angle
- * brackets. It may be one of these characters: / > = ! ?
or it
+ * brackets. It may be one of these characters: / > = ! ? or it
* may be a string wrapped in single quotes or double quotes, or it may be a
* name.
+ * }
* @return a String or a Character.
* @throws JSONException If the XML is not well formed.
*/
diff --git a/src/test/java/org/json/junit/CDLTest.java b/src/test/java/org/json/junit/CDLTest.java
index 721fd3c..48586b7 100644
--- a/src/test/java/org/json/junit/CDLTest.java
+++ b/src/test/java/org/json/junit/CDLTest.java
@@ -1,5 +1,29 @@
package org.json.junit;
+/*
+Copyright (c) 2020 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
import static org.junit.Assert.*;
import org.junit.Test;
diff --git a/src/test/java/org/json/junit/CookieListTest.java b/src/test/java/org/json/junit/CookieListTest.java
index 7149644..c3f647f 100644
--- a/src/test/java/org/json/junit/CookieListTest.java
+++ b/src/test/java/org/json/junit/CookieListTest.java
@@ -1,5 +1,29 @@
package org.json.junit;
+/*
+Copyright (c) 2020 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
import static org.junit.Assert.*;
import java.util.*;
diff --git a/src/test/java/org/json/junit/CookieTest.java b/src/test/java/org/json/junit/CookieTest.java
index 4b7ca44..74756aa 100644
--- a/src/test/java/org/json/junit/CookieTest.java
+++ b/src/test/java/org/json/junit/CookieTest.java
@@ -1,6 +1,28 @@
package org.json.junit;
+/*
+Copyright (c) 2020 JSON.org
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
import static org.junit.Assert.*;
diff --git a/src/test/java/org/json/junit/EnumTest.java b/src/test/java/org/json/junit/EnumTest.java
index 366643e..ed2c87a 100644
--- a/src/test/java/org/json/junit/EnumTest.java
+++ b/src/test/java/org/json/junit/EnumTest.java
@@ -1,5 +1,29 @@
package org.json.junit;
+/*
+Copyright (c) 2020 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
diff --git a/src/test/java/org/json/junit/HTTPTest.java b/src/test/java/org/json/junit/HTTPTest.java
index 2716c3c..8182b60 100644
--- a/src/test/java/org/json/junit/HTTPTest.java
+++ b/src/test/java/org/json/junit/HTTPTest.java
@@ -1,5 +1,29 @@
package org.json.junit;
+/*
+Copyright (c) 2020 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
import static org.junit.Assert.*;
import org.json.*;
diff --git a/src/test/java/org/json/junit/JSONArrayTest.java b/src/test/java/org/json/junit/JSONArrayTest.java
index 5aef340..b358b7a 100644
--- a/src/test/java/org/json/junit/JSONArrayTest.java
+++ b/src/test/java/org/json/junit/JSONArrayTest.java
@@ -1,5 +1,29 @@
package org.json.junit;
+/*
+Copyright (c) 2020 JSON.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+The Software shall be used for Good, not Evil.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@@ -9,13 +33,7 @@ import java.io.IOException;
import java.io.StringWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import org.json.JSONArray;
import org.json.JSONException;
@@ -753,49 +771,74 @@ public class JSONArrayTest {
"]" +
"]";
- String jsonArray1Str =
- "[\n" +
- " [\n" +
- " 1,\n" +
- " 2,\n" +
- " {\"key3\": true}\n" +
- " ],\n" +
- " {\n" +
- " \"key1\": \"val1\",\n" +
- " \"key2\": {\"key2\": \"val2\"}\n" +
- " },\n" +
- " [\n" +
- " [\n" +
- " 1,\n" +
- " 2.1\n" +
- " ],\n" +
- " [null]\n" +
- " ]\n" +
- "]";
- String jsonArray4Str =
- "[\n" +
- " [\n" +
- " 1,\n" +
- " 2,\n" +
- " {\"key3\": true}\n" +
- " ],\n" +
- " {\n" +
- " \"key1\": \"val1\",\n" +
- " \"key2\": {\"key2\": \"val2\"}\n" +
- " },\n" +
- " [\n" +
- " [\n" +
- " 1,\n" +
- " 2.1\n" +
- " ],\n" +
- " [null]\n" +
- " ]\n" +
- "]";
+ String jsonArray1Strs [] =
+ {
+ "[",
+ " [",
+ " 1,",
+ " 2,",
+ " {\"key3\": true}",
+ " ],",
+ " {",
+ " \"key1\": \"val1\",",
+ " \"key2\": {\"key2\": \"val2\"}",
+ " },",
+ " [",
+ " [",
+ " 1,",
+ " 2.1",
+ " ],",
+ " [null]",
+ " ]",
+ "]"
+ };
+ String jsonArray4Strs [] =
+ {
+ "[",
+ " [",
+ " 1,",
+ " 2,",
+ " {\"key3\": true}",
+ " ],",
+ " {",
+ " \"key1\": \"val1\",",
+ " \"key2\": {\"key2\": \"val2\"}",
+ " },",
+ " [",
+ " [",
+ " 1,",
+ " 2.1",
+ " ],",
+ " [null]",
+ " ]",
+ "]"
+ };
JSONArray jsonArray = new JSONArray(jsonArray0Str);
- assertEquals(jsonArray0Str, jsonArray.toString());
- assertEquals(jsonArray0Str, jsonArray.toString(0));
- assertEquals(jsonArray1Str, jsonArray.toString(1));
- assertEquals(jsonArray4Str, jsonArray.toString(4));
+ String [] actualStrArray = jsonArray.toString().split("\\r?\\n");
+ assertEquals("Expected 1 line", 1, actualStrArray.length);
+ actualStrArray = jsonArray.toString(0).split("\\r?\\n");
+ assertEquals("Expected 1 line", 1, actualStrArray.length);
+
+ actualStrArray = jsonArray.toString(1).split("\\r?\\n");
+ assertEquals("Expected lines", jsonArray1Strs.length, actualStrArray.length);
+ List