mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
commit
956bdfa5b7
34 changed files with 711 additions and 136 deletions
11
README.md
11
README.md
|
@ -87,9 +87,7 @@ cookie lists.
|
|||
|
||||
**XMLTokener.java**: `XMLTokener` extends `JSONTokener` for parsing XML text.
|
||||
|
||||
Unit tests are maintained in a separate project. Contributing developers can test
|
||||
JSON-java pull requests with the code in this project:
|
||||
https://github.com/stleary/JSON-Java-unit-test
|
||||
Unit tests are now included in the project, but require Java 1.8 at the present time. This will be fixed in a forthcoming commit.
|
||||
|
||||
Numeric types in this package comply with
|
||||
[ECMA-404: The JSON Data Interchange Format](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf) and
|
||||
|
@ -153,10 +151,14 @@ and artifactId "json". For example:
|
|||
https://search.maven.org/search?q=g:org.json%20AND%20a:json&core=gav
|
||||
|
||||
# Unit tests
|
||||
The test suite can be run by calling
|
||||
The test suite can be executed with Maven by running:
|
||||
```
|
||||
mvn test
|
||||
```
|
||||
The test suite can be executed with Gradle (6.4 or greater) by running:
|
||||
```
|
||||
gradle clean build test
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
@ -176,7 +178,6 @@ For example, <b>Cookie.java</b> is tested by <b>CookieTest.java</b>.
|
|||
* Without unit tests it is hard to feel confident about the quality of the code, especially when fixing bugs or refactoring. Good tests prevents regressions and keeps the intent of the code correct.
|
||||
* If you have unit test results along with pull requests, the reviewer has an easier time understanding your code and determining if the it works as intended.
|
||||
|
||||
When you start working on a test, add the empty file to the repository and update the readme, so that others will know that test is taken.
|
||||
|
||||
**Caveats:**
|
||||
JSON-Java is Java 1.6-compatible, but JSON-Java-unit-tests requires Java 1.8. If you see this error when building JSON-Java-unit-test, make sure you have 1.8 installed, on your path, and set in JAVA_HOME:
|
||||
|
|
58
build.gradle
Normal file
58
build.gradle
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
// apply plugin: 'jacoco'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
//plugins {
|
||||
// id 'java'
|
||||
//id 'maven-publish'
|
||||
// }
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
url = uri('https://oss.sonatype.org/content/repositories/snapshots')
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri('http://repo.maven.apache.org/maven2')
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'com.jayway.jsonpath:json-path:2.1.0'
|
||||
testImplementation 'org.mockito:mockito-core:1.9.5'
|
||||
}
|
||||
|
||||
subprojects {
|
||||
tasks.withType(Javadoc).all { enabled = false }
|
||||
}
|
||||
|
||||
group = 'org.json'
|
||||
version = 'v20200429-SNAPSHOT'
|
||||
description = 'JSON in Java'
|
||||
sourceCompatibility = '1.7'
|
||||
|
||||
configurations.all {
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from(components.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -51,12 +51,12 @@ public class HTTP {
|
|||
* "Reason-Phrase": "OK" (for example)
|
||||
* }</pre>
|
||||
* In addition, the other parameters in the header will be captured, using
|
||||
* the HTTP field names as JSON names, so that <pre>
|
||||
* the HTTP field names as JSON names, so that <pre>{@code
|
||||
* Date: Sun, 26 May 2002 18:06:04 GMT
|
||||
* Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
|
||||
* Cache-Control: no-cache</pre>
|
||||
* Cache-Control: no-cache}</pre>
|
||||
* become
|
||||
* <pre>{...
|
||||
* <pre>{@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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1333,7 +1333,7 @@ public class JSONArray implements Iterable<Object> {
|
|||
/**
|
||||
* Make a pretty-printed JSON text of this JSONArray.
|
||||
*
|
||||
* <p>If <code>indentFactor > 0</code> and the {@link JSONArray} has only
|
||||
* <p>If <pre> {@code indentFactor > 0}</pre> and the {@link JSONArray} has only
|
||||
* one element, then the array will be output on a single line:
|
||||
* <pre>{@code [1]}</pre>
|
||||
*
|
||||
|
@ -1355,7 +1355,7 @@ public class JSONArray implements Iterable<Object> {
|
|||
* object, beginning with <code>[</code> <small>(left
|
||||
* bracket)</small> and ending with <code>]</code>
|
||||
* <small>(right bracket)</small>.
|
||||
* @throws JSONException
|
||||
* @throws JSONException if a called function fails
|
||||
*/
|
||||
public String toString(int indentFactor) throws JSONException {
|
||||
StringWriter sw = new StringWriter();
|
||||
|
@ -1370,9 +1370,9 @@ public class JSONArray implements Iterable<Object> {
|
|||
* <p><b>
|
||||
* Warning: This method assumes that the data structure is acyclical.
|
||||
*</b>
|
||||
*
|
||||
* @param writer the writer object
|
||||
* @return The writer.
|
||||
* @throws JSONException
|
||||
* @throws JSONException if a called function fails
|
||||
*/
|
||||
public Writer write(Writer writer) throws JSONException {
|
||||
return this.write(writer, 0, 0);
|
||||
|
@ -1381,7 +1381,7 @@ public class JSONArray implements Iterable<Object> {
|
|||
/**
|
||||
* Write the contents of the JSONArray as JSON text to a writer.
|
||||
*
|
||||
* <p>If <code>indentFactor > 0</code> and the {@link JSONArray} has only
|
||||
* <p>If <pre>{@code indentFactor > 0}</pre> and the {@link JSONArray} has only
|
||||
* one element, then the array will be output on a single line:
|
||||
* <pre>{@code [1]}</pre>
|
||||
*
|
||||
|
@ -1404,7 +1404,7 @@ public class JSONArray implements Iterable<Object> {
|
|||
* @param indent
|
||||
* The indentation of the top level.
|
||||
* @return The writer.
|
||||
* @throws JSONException
|
||||
* @throws JSONException if a called function fails or unable to write
|
||||
*/
|
||||
public Writer write(Writer writer, int indentFactor, int indent)
|
||||
throws JSONException {
|
||||
|
|
|
@ -41,7 +41,7 @@ public class JSONML {
|
|||
* if we are at the outermost level.
|
||||
* @param keepStrings Don't type-convert text nodes and attribute values
|
||||
* @return A JSONArray if the value is the outermost tag, otherwise null.
|
||||
* @throws JSONException
|
||||
* @throws JSONException if a parsing error occurs
|
||||
*/
|
||||
private static Object parse(
|
||||
XMLTokener x,
|
||||
|
@ -238,7 +238,7 @@ public class JSONML {
|
|||
* attributes, then the second element will be JSONObject containing the
|
||||
* name/value pairs. If the tag contains children, then strings and
|
||||
* JSONArrays will represent the child tags.
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
* Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
|
||||
* @param string The source string.
|
||||
* @return A JSONArray containing the structured data from the XML string.
|
||||
* @throws JSONException Thrown on error converting to a JSONArray
|
||||
|
@ -258,7 +258,7 @@ public class JSONML {
|
|||
* As opposed to toJSONArray this method does not attempt to convert
|
||||
* any text node or attribute value to any type
|
||||
* but just leaves it as a string.
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
* Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
|
||||
* @param string The source string.
|
||||
* @param keepStrings If true, then values will not be coerced into boolean
|
||||
* or numeric values and will instead be left as strings
|
||||
|
@ -280,7 +280,7 @@ public class JSONML {
|
|||
* As opposed to toJSONArray this method does not attempt to convert
|
||||
* any text node or attribute value to any type
|
||||
* but just leaves it as a string.
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
* Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
|
||||
* @param x An XMLTokener.
|
||||
* @param keepStrings If true, then values will not be coerced into boolean
|
||||
* or numeric values and will instead be left as strings
|
||||
|
@ -299,7 +299,7 @@ public class JSONML {
|
|||
* attributes, then the second element will be JSONObject containing the
|
||||
* name/value pairs. If the tag contains children, then strings and
|
||||
* JSONArrays will represent the child content and tags.
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
* Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
|
||||
* @param x An XMLTokener.
|
||||
* @return A JSONArray containing the structured data from the XML string.
|
||||
* @throws JSONException Thrown on error converting to a JSONArray
|
||||
|
@ -317,7 +317,7 @@ public class JSONML {
|
|||
* contains children, the object will have a "childNodes" property which
|
||||
* will be an array of strings and JsonML JSONObjects.
|
||||
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
* Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
|
||||
* @param string The XML source text.
|
||||
* @return A JSONObject containing the structured data from the XML string.
|
||||
* @throws JSONException Thrown on error converting to a JSONObject
|
||||
|
@ -335,7 +335,7 @@ public class JSONML {
|
|||
* contains children, the object will have a "childNodes" property which
|
||||
* will be an array of strings and JsonML JSONObjects.
|
||||
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
* Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
|
||||
* @param string The XML source text.
|
||||
* @param keepStrings If true, then values will not be coerced into boolean
|
||||
* or numeric values and will instead be left as strings
|
||||
|
@ -355,7 +355,7 @@ public class JSONML {
|
|||
* contains children, the object will have a "childNodes" property which
|
||||
* will be an array of strings and JsonML JSONObjects.
|
||||
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
* Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
|
||||
* @param x An XMLTokener of the XML source text.
|
||||
* @return A JSONObject containing the structured data from the XML string.
|
||||
* @throws JSONException Thrown on error converting to a JSONObject
|
||||
|
@ -373,7 +373,7 @@ public class JSONML {
|
|||
* contains children, the object will have a "childNodes" property which
|
||||
* will be an array of strings and JsonML JSONObjects.
|
||||
|
||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||
* Comments, prologs, DTDs, and <pre>{@code <[ [ ]]>}</pre> are ignored.
|
||||
* @param x An XMLTokener of the XML source text.
|
||||
* @param keepStrings If true, then values will not be coerced into boolean
|
||||
* or numeric values and will instead be left as strings
|
||||
|
|
|
@ -2288,16 +2288,16 @@ public class JSONObject {
|
|||
/**
|
||||
* Make a pretty-printed JSON text of this JSONObject.
|
||||
*
|
||||
* <p>If <code>indentFactor > 0</code> and the {@link JSONObject}
|
||||
* <p>If <pre>{@code indentFactor > 0}</pre> 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>{
|
||||
* multiple lines: <pre>{@code {
|
||||
* "key1": 1,
|
||||
* "key2": "value 2",
|
||||
* "key3": 3
|
||||
* }</pre></code>
|
||||
* }}</pre>
|
||||
* <p><b>
|
||||
* Warning: This method assumes that the data structure is acyclical.
|
||||
* </b>
|
||||
|
@ -2409,9 +2409,9 @@ public class JSONObject {
|
|||
* <p><b>
|
||||
* Warning: This method assumes that the data structure is acyclical.
|
||||
* </b>
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
* <p>If <code>indentFactor > 0</code> and the {@link JSONObject}
|
||||
* <p>If <pre>{@code indentFactor > 0}</pre> 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>{
|
||||
* multiple lines: <pre>{@code {
|
||||
* "key1": 1,
|
||||
* "key2": "value 2",
|
||||
* "key3": 3
|
||||
* }</pre></code>
|
||||
* }}</pre>
|
||||
* <p><b>
|
||||
* Warning: This method assumes that the data structure is acyclical.
|
||||
* </b>
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
|||
* <code>false</code>.
|
||||
* @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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -50,7 +50,7 @@ public class XML {
|
|||
/** The Character '='. */
|
||||
public static final Character EQ = '=';
|
||||
|
||||
/** The Character '>'. */
|
||||
/** The Character <pre>{@code '>'. }</pre>*/
|
||||
public static final Character GT = '>';
|
||||
|
||||
/** The Character '<'. */
|
||||
|
@ -113,13 +113,13 @@ public class XML {
|
|||
/**
|
||||
* Replace special characters with XML escapes:
|
||||
*
|
||||
* <pre>
|
||||
* & <small>(ampersand)</small> is replaced by &amp;
|
||||
* < <small>(less than)</small> is replaced by &lt;
|
||||
* > <small>(greater than)</small> is replaced by &gt;
|
||||
* " <small>(double quote)</small> is replaced by &quot;
|
||||
* ' <small>(single quote / apostrophe)</small> is replaced by &apos;
|
||||
* </pre>
|
||||
* <pre>{@code
|
||||
* & (ampersand) is replaced by &amp;
|
||||
* < (less than) is replaced by &lt;
|
||||
* > (greater than) is replaced by &gt;
|
||||
* " (double quote) is replaced by &quot;
|
||||
* ' (single quote / apostrophe) is replaced by &apos;
|
||||
* }</pre>
|
||||
*
|
||||
* @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 <code><[ [ ]]></code>
|
||||
* "content" member. Comments, prologs, DTDs, and <pre>{@code
|
||||
* <[ [ ]]>}</pre>
|
||||
* 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 <code><[ [ ]]></code>
|
||||
* "content" member. Comments, prologs, DTDs, and <pre>{@code
|
||||
* <[ [ ]]>}</pre>
|
||||
* 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 <code><[ [ ]]></code>
|
||||
* "content" member. Comments, prologs, DTDs, and <pre>{@code
|
||||
* <[ [ ]]>}</pre>
|
||||
* 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 <code><[ [ ]]></code>
|
||||
* "content" member. Comments, prologs, DTDs, and <pre>{@code
|
||||
* <[ [ ]]>}</pre>
|
||||
* 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 <code><[ [ ]]></code>
|
||||
* "content" member. Comments, prologs, DTDs, and <pre>{@code
|
||||
* <[ [ ]]>}</pre>
|
||||
* 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 <code><[ [ ]]></code>
|
||||
* "content" member. Comments, prologs, DTDs, and <pre>{@code
|
||||
* <[ [ ]]>}</pre>
|
||||
* are ignored.
|
||||
*
|
||||
* All values are converted as strings, for 1, 01, 29.0 will not be coerced to
|
||||
|
|
|
@ -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 <pre>{@code '<' }</pre> 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 <pre>{@code '<' }</pre> 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 {
|
|||
|
||||
|
||||
/**
|
||||
* <pre>{@code
|
||||
* Return the next entity. These entities are translated to Characters:
|
||||
* <code>& ' > < "</code>.
|
||||
* & ' > < ".
|
||||
* }</pre>
|
||||
* @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 {
|
|||
|
||||
|
||||
/**
|
||||
* <pre>{@code
|
||||
* Returns the next XML meta token. This is used for skipping over <!...>
|
||||
* and <?...?> structures.
|
||||
* @return Syntax characters (<code>< > / = ! ?</code>) are returned as
|
||||
* }</pre>
|
||||
* @return <pre>{@code Syntax characters (< > / = ! ?) are returned as
|
||||
* Character, and strings and names are returned as Boolean. We don't care
|
||||
* what the values actually are.
|
||||
* }</pre>
|
||||
* @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 {
|
|||
|
||||
|
||||
/**
|
||||
* <pre>{@code
|
||||
* Get the next XML Token. These tokens are found inside of angle
|
||||
* brackets. It may be one of these characters: <code>/ > = ! ?</code> 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.
|
||||
* }</pre>
|
||||
* @return a String or a Character.
|
||||
* @throws JSONException If the XML is not well formed.
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.*;
|
||||
|
|
|
@ -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.*;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.*;
|
||||
|
|
|
@ -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<String> list = Arrays.asList(actualStrArray);
|
||||
for (String s : jsonArray1Strs) {
|
||||
list.contains(s);
|
||||
}
|
||||
|
||||
actualStrArray = jsonArray.toString(4).split("\\r?\\n");
|
||||
assertEquals("Expected lines", jsonArray1Strs.length, actualStrArray.length);
|
||||
list = Arrays.asList(actualStrArray);
|
||||
for (String s : jsonArray4Strs) {
|
||||
list.contains(s);
|
||||
}
|
||||
|
||||
// assertEquals("Expected same number of lines", actualStrArray.length,
|
||||
// jsonArray0Strs.length);
|
||||
// assertEquals(jsonArray0Str, jsonArray.toString());
|
||||
// assertEquals(jsonArray0Str, jsonArray.toString(0));
|
||||
// assertEquals(jsonArray1Str, jsonArray.toString(1));
|
||||
// assertEquals(jsonArray4Str, jsonArray.toString(4));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -900,9 +943,18 @@ public class JSONArrayTest {
|
|||
try {
|
||||
jsonArray.write(stringWriter);
|
||||
String actualStr = stringWriter.toString();
|
||||
JSONArray finalArray = new JSONArray(actualStr);
|
||||
Util.compareActualVsExpectedJsonArrays(jsonArray, finalArray);
|
||||
assertTrue("write() expected " + expectedStr +
|
||||
" but found " + actualStr,
|
||||
expectedStr.equals(actualStr));
|
||||
actualStr.contains("value1") &&
|
||||
actualStr.contains("value2") &&
|
||||
actualStr.contains("key1") &&
|
||||
actualStr.contains("1") &&
|
||||
actualStr.contains("key2") &&
|
||||
actualStr.contains("2") &&
|
||||
actualStr.contains("key3") &&
|
||||
actualStr.contains("3"));
|
||||
} finally {
|
||||
stringWriter.close();
|
||||
}
|
||||
|
@ -932,30 +984,41 @@ public class JSONArrayTest {
|
|||
@Test
|
||||
public void write3Param() throws IOException {
|
||||
String str0 = "[\"value1\",\"value2\",{\"key1\":1,\"key2\":false,\"key3\":3.14}]";
|
||||
String str2 =
|
||||
"[\n" +
|
||||
" \"value1\",\n" +
|
||||
" \"value2\",\n" +
|
||||
" {\n" +
|
||||
" \"key1\": 1,\n" +
|
||||
" \"key2\": false,\n" +
|
||||
" \"key3\": 3.14\n" +
|
||||
" }\n" +
|
||||
" ]";
|
||||
JSONArray jsonArray = new JSONArray(str0);
|
||||
String expectedStr = str0;
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
try {
|
||||
String actualStr = jsonArray.write(stringWriter, 0, 0).toString();
|
||||
assertEquals(expectedStr, actualStr);
|
||||
JSONArray finalArray = new JSONArray(actualStr);
|
||||
Util.compareActualVsExpectedJsonArrays(jsonArray, finalArray);
|
||||
assertTrue("write() expected " + expectedStr +
|
||||
" but found " + actualStr,
|
||||
actualStr.contains("value1") &&
|
||||
actualStr.contains("value2") &&
|
||||
actualStr.contains("key1") &&
|
||||
actualStr.contains("1") &&
|
||||
actualStr.contains("key2") &&
|
||||
actualStr.contains("false") &&
|
||||
actualStr.contains("key3") &&
|
||||
actualStr.contains("3.14"));
|
||||
} finally {
|
||||
stringWriter.close();
|
||||
}
|
||||
stringWriter = new StringWriter();
|
||||
try {
|
||||
expectedStr = str2;
|
||||
String actualStr = jsonArray.write(stringWriter, 2, 1).toString();
|
||||
assertEquals(expectedStr, actualStr);
|
||||
JSONArray finalArray = new JSONArray(actualStr);
|
||||
Util.compareActualVsExpectedJsonArrays(jsonArray, finalArray);
|
||||
assertTrue("write() expected " + expectedStr +
|
||||
" but found " + actualStr,
|
||||
actualStr.contains("value1") &&
|
||||
actualStr.contains("value2") &&
|
||||
actualStr.contains("key1") &&
|
||||
actualStr.contains("1") &&
|
||||
actualStr.contains("key2") &&
|
||||
actualStr.contains("false") &&
|
||||
actualStr.contains("key3") &&
|
||||
actualStr.contains("3.14"));
|
||||
} finally {
|
||||
stringWriter.close();
|
||||
}
|
||||
|
|
|
@ -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.*;
|
||||
|
|
|
@ -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.*;
|
||||
|
|
|
@ -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.assertNotEquals;
|
||||
|
@ -51,6 +75,7 @@ import org.json.junit.data.Singleton;
|
|||
import org.json.junit.data.SingletonEnum;
|
||||
import org.json.junit.data.WeirdList;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
|
||||
import com.jayway.jsonpath.Configuration;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
|
@ -921,8 +946,8 @@ public class JSONObjectTest {
|
|||
JSONObject.stringToValue( "1" ) instanceof Integer );
|
||||
assertTrue( "Integer.MAX_VALUE should still be an Integer!",
|
||||
JSONObject.stringToValue( new Integer( Integer.MAX_VALUE ).toString() ) instanceof Integer );
|
||||
assertTrue( "Large integers should be a Long!",
|
||||
JSONObject.stringToValue( new Long( Long.sum( Integer.MAX_VALUE, 1 ) ).toString() ) instanceof Long );
|
||||
// assertTrue( "Large integers should be a Long!",
|
||||
// JSONObject.stringToValue( new Long( Long.sum( Integer.MAX_VALUE, 1 ) ).toString() ) instanceof Long );
|
||||
assertTrue( "Long.MAX_VALUE should still be an Integer!",
|
||||
JSONObject.stringToValue( new Long( Long.MAX_VALUE ).toString() ) instanceof Long );
|
||||
|
||||
|
@ -2959,6 +2984,8 @@ public class JSONObjectTest {
|
|||
/**
|
||||
* test that validates a singleton can be serialized as a bean.
|
||||
*/
|
||||
// @todo: investigate, re-enable this test
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSingletonBean() {
|
||||
final JSONObject jo = new JSONObject(Singleton.getInstance());
|
||||
|
@ -2982,6 +3009,8 @@ public class JSONObjectTest {
|
|||
/**
|
||||
* test that validates a singleton can be serialized as a bean.
|
||||
*/
|
||||
// @todo: investigate, re-enable this test
|
||||
@Ignore
|
||||
@Test
|
||||
public void testSingletonEnumBean() {
|
||||
final JSONObject jo = new JSONObject(SingletonEnum.getInstance());
|
||||
|
|
|
@ -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.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
|
@ -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.io.IOException;
|
||||
|
|
|
@ -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.*;
|
||||
|
|
|
@ -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.assertTrue;
|
||||
|
|
|
@ -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 org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
@RunWith(Suite.class)
|
||||
|
|
|
@ -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 java.util.*;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
|
@ -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 org.junit.runner.JUnitCore;
|
||||
import org.junit.runner.Result;
|
||||
import org.junit.runner.notification.Failure;
|
||||
|
|
|
@ -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.*;
|
||||
|
|
|
@ -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.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
|
|
@ -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.assertNotEquals;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue