diff --git a/.classpath b/.classpath new file mode 100644 index 000000000..89242250d --- /dev/null +++ b/.classpath @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 98ee6c185..0eb932ecd 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -11,38 +11,12 @@ on: jobs: # old-school build and jar method. No tests run or compiled. - build-1_6: - runs-on: ubuntu-16.04 - strategy: - matrix: - # build for java 1.6, however don't run any tests - java: [ 1.6 ] - name: Java ${{ matrix.java }} - steps: - - uses: actions/checkout@v2 - - name: Setup java - uses: actions/setup-java@v1 - with: - java-version: ${{ matrix.java }} - - name: Compile Java ${{ matrix.java }} - run: | - mkdir -p target/classes - javac -d target/classes/ src/main/java/org/json/*.java - - name: Create java ${{ matrix.java }} JAR - run: | - jar cvf target/org.json.jar -C target/classes . - - name: Upload Java ${{ matrix.java }} JAR - uses: actions/upload-artifact@v1 - with: - name: Java ${{ matrix.java }} JAR - path: target/org.json.jar - build: runs-on: ubuntu-16.04 strategy: matrix: # build against supported Java LTS versions: - java: [ 1.7, 8, 11 ] + java: [ 8, 11 ] name: Java ${{ matrix.java }} steps: - uses: actions/checkout@v2 @@ -71,4 +45,4 @@ jobs: uses: actions/upload-artifact@v1 with: name: Test Report ${{ matrix.java }} - path: target/site/ \ No newline at end of file + path: target/site/ diff --git a/.gitignore b/.gitignore index 7794c4cbe..7c3d5312b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/bin/ +/target/ # ignore eclipse project files .project .classpath @@ -14,3 +16,6 @@ build /gradlew /gradlew.bat .gitmodules + + +tmp/ \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 000000000..8b2cd9b36 --- /dev/null +++ b/.project @@ -0,0 +1,36 @@ + + + JSON-java + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/README.md b/README.md index 82c615720..13c9c677c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ +# Modification notice + +Replace internal container implementation to ordered one, ``HashMap`` ==> ``LinkedHashMap`` . + +Maven dependency registered: + +``` + + com.github.tsohr + json + 0.0.2 + +``` + + * Minimum Java version set to 1.8 + + + JSON in Java [package org.json] =============================== diff --git a/pom.xml b/pom.xml index e5449ba8c..ed5f27864 100644 --- a/pom.xml +++ b/pom.xml @@ -1,193 +1,190 @@ + - 4.0.0 - - org.json - json - v20200429-SNAPSHOT - bundle - - JSON in Java - - JSON is a light-weight, language independent, data interchange format. - See http://www.JSON.org/ - - The files in this package implement JSON encoders/decoders in Java. - It also includes the capability to convert between JSON and XML, HTTP - headers, Cookies, and CDL. - - This is a reference implementation. There is a large number of JSON packages - in Java. Perhaps someday the Java community will standardize on one. Until - then, choose carefully. - - The license includes this restriction: "The software shall be used for good, - not evil." If your conscience cannot live with that, then choose a different - package. - - https://github.com/douglascrockford/JSON-java - - - org.sonatype.oss - oss-parent - 9 - - - - https://github.com/douglascrockford/JSON-java.git - scm:git:git://github.com/douglascrockford/JSON-java.git - scm:git:git@github.com:douglascrockford/JSON-java.git - - - - - The JSON License - http://json.org/license.html - repo - Copyright (c) 2002 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. + 4.0.0 + com.github.tsohr + json + 0.0.2 + json-ordered + Ordered version of JSONObject + https://github.com/tsohr/JSON-java + + scm:git:https://github.com/tsohr/JSON-java.git + scm:git:https://github.com/tsohr/JSON-java.git + https://github.com/tsohr/JSON-java + + + + The JSON License + http://json.org/license.html + repo + Copyright (c) 2002 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. - - + + Douglas Crockford douglas@crockford.com + + Younghwan Kim + sohrkim@gmail.com + Github + https://github.com/tsohr + - - UTF-8 - - - - - - junit - junit + + UTF-8 + + + + junit + junit 4.13.1 - test - - - com.jayway.jsonpath - json-path - 2.1.0 - test - - - org.mockito - mockito-core - 1.9.5 - test - - - - - - - org.apache.felix - maven-bundle-plugin - 3.0.1 - true - - - - org.json - - ${project.artifactId} - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.6 - 1.6 - - - - org.apache.maven.plugins - maven-source-plugin - 2.1.2 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.7 - - - attach-javadocs - - jar - - - -Xdoclint:none - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin + test + + + com.jayway.jsonpath + json-path + 2.1.0 + test + + + org.mockito + mockito-core + 1.9.5 + test + + + + src/ + test/ + + + test/resources/ + + **/*.java + + false + + + + + + maven-compiler-plugin + 3.6.1 + + 1.8 + 1.8 + UTF-8 + + + + org.apache.felix + maven-bundle-plugin + 3.0.1 + true + + + + com.github.tsohr + + ${project.artifactId} + + + + + org.apache.maven.plugins + maven-source-plugin + 2.1.2 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.7 + + + attach-javadocs + + jar + + + -Xdoclint:none + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + + + org.apache.maven.plugins + maven-release-plugin + + forked-path + false + -Psonatype-oss-release + + + + org.sonatype.plugins + nexus-staging-maven-plugin 1.6.3 - true - - ossrh - https://oss.sonatype.org/ - false - - - - org.apache.maven.plugins - maven-jar-plugin - 3.2.0 - - - - org.json - - - - - - + true + + ossrh + https://oss.sonatype.org/ + true + + + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + diff --git a/src/main/java/org/json/CDL.java b/src/com/github/tsohr/CDL.java similarity index 99% rename from src/main/java/org/json/CDL.java rename to src/com/github/tsohr/CDL.java index f12cfc054..9467ed07d 100644 --- a/src/main/java/org/json/CDL.java +++ b/src/com/github/tsohr/CDL.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/Cookie.java b/src/com/github/tsohr/Cookie.java similarity index 99% rename from src/main/java/org/json/Cookie.java rename to src/com/github/tsohr/Cookie.java index a43d1eddd..b1ce2cd79 100644 --- a/src/main/java/org/json/Cookie.java +++ b/src/com/github/tsohr/Cookie.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; import java.util.Locale; diff --git a/src/main/java/org/json/CookieList.java b/src/com/github/tsohr/CookieList.java similarity index 99% rename from src/main/java/org/json/CookieList.java rename to src/com/github/tsohr/CookieList.java index 83b2630e5..bb33f90cc 100644 --- a/src/main/java/org/json/CookieList.java +++ b/src/com/github/tsohr/CookieList.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/HTTP.java b/src/com/github/tsohr/HTTP.java similarity index 99% rename from src/main/java/org/json/HTTP.java rename to src/com/github/tsohr/HTTP.java index cc01167c6..f1d0fd2f4 100644 --- a/src/main/java/org/json/HTTP.java +++ b/src/com/github/tsohr/HTTP.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/HTTPTokener.java b/src/com/github/tsohr/HTTPTokener.java similarity index 98% rename from src/main/java/org/json/HTTPTokener.java rename to src/com/github/tsohr/HTTPTokener.java index 16c7081a9..33f59c396 100644 --- a/src/main/java/org/json/HTTPTokener.java +++ b/src/com/github/tsohr/HTTPTokener.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/JSONArray.java b/src/com/github/tsohr/JSONArray.java similarity index 99% rename from src/main/java/org/json/JSONArray.java rename to src/com/github/tsohr/JSONArray.java index 2a8a1d209..82dbc0f74 100644 --- a/src/main/java/org/json/JSONArray.java +++ b/src/com/github/tsohr/JSONArray.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/JSONException.java b/src/com/github/tsohr/JSONException.java similarity index 98% rename from src/main/java/org/json/JSONException.java rename to src/com/github/tsohr/JSONException.java index ab7ff77dc..196aa8c47 100644 --- a/src/main/java/org/json/JSONException.java +++ b/src/com/github/tsohr/JSONException.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/JSONML.java b/src/com/github/tsohr/JSONML.java similarity index 99% rename from src/main/java/org/json/JSONML.java rename to src/com/github/tsohr/JSONML.java index aafdf7277..9cda038d8 100644 --- a/src/main/java/org/json/JSONML.java +++ b/src/com/github/tsohr/JSONML.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2008 JSON.org diff --git a/src/main/java/org/json/JSONObject.java b/src/com/github/tsohr/JSONObject.java similarity index 95% rename from src/main/java/org/json/JSONObject.java rename to src/com/github/tsohr/JSONObject.java index 8bbb874b3..01bee8222 100644 --- a/src/main/java/org/json/JSONObject.java +++ b/src/com/github/tsohr/JSONObject.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; import java.io.Closeable; @@ -38,8 +38,8 @@ of this software and associated documentation files (the "Software"), to deal import java.math.BigInteger; import java.util.Collection; import java.util.Enumeration; -import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; @@ -181,7 +181,7 @@ public JSONObject() { // implementations to rearrange their items for a faster element // retrieval based on associative access. // Therefore, an implementation mustn't rely on the order of the item. - this.map = new HashMap(); + this.map = new LinkedHashMap(); } /** @@ -286,9 +286,9 @@ public JSONObject(JSONTokener x) throws JSONException { */ public JSONObject(Map m) { if (m == null) { - this.map = new HashMap(); + this.map = new LinkedHashMap(); } else { - this.map = new HashMap(m.size()); + this.map = new LinkedHashMap(m.size()); for (final Entry e : m.entrySet()) { if(e.getKey() == null) { throw new NullPointerException("Null key."); @@ -457,7 +457,7 @@ public JSONObject(String baseName, Locale locale) throws JSONException { * @param initialCapacity initial capacity of the internal map. */ protected JSONObject(int initialCapacity){ - this.map = new HashMap(initialCapacity); + this.map = new LinkedHashMap(initialCapacity); } /** @@ -1132,6 +1132,33 @@ public boolean optBoolean(String key, boolean defaultValue) { return defaultValue; } } + + /** + * Get an optional boolean associated with a key. It returns the + * defaultValue if there is no such key, or if it is not a Boolean or the + * String "true" or "false" (case insensitive). + * + * @param key + * A key string. + * @param defaultValue + * The default. + * @return The truth. including null + */ + public Boolean optBooleanNullable(String key, Boolean defaultValue) { + Object val = this.opt(key); + if (NULL.equals(val)) { + return defaultValue; + } + if (val instanceof Boolean){ + return ((Boolean) val).booleanValue(); + } + try { + // we'll use the get anyway because it does string conversion. + return this.getBoolean(key); + } catch (Exception e) { + return defaultValue; + } + } /** * Get an optional BigDecimal associated with a key, or the defaultValue if @@ -1280,6 +1307,29 @@ public double optDouble(String key, double defaultValue) { // } return doubleValue; } + + /** + * Get an optional double associated with a key, or the defaultValue if + * there is no such key or if its value is not a number. If the value is a + * string, an attempt will be made to evaluate it as a number. + * + * @param key + * A key string. + * @param defaultValue + * The default. + * @return An object which is the value. including null + */ + public Double optDoubleNullable(String key, Double defaultValue) { + Number val = this.optNumber(key); + if (val == null) { + return defaultValue; + } + final double doubleValue = val.doubleValue(); + // if (Double.isNaN(doubleValue) || Double.isInfinite(doubleValue)) { + // return defaultValue; + // } + return doubleValue; + } /** * Get the optional double value associated with an index. NaN is returned @@ -1317,6 +1367,29 @@ public float optFloat(String key, float defaultValue) { return floatValue; } + /** + * Get the optional double value associated with an index. The defaultValue + * is returned if there is no value for the index, or if the value is not a + * number and cannot be converted to a number. + * + * @param key + * A key string. + * @param defaultValue + * The default value. + * @return The value. including null + */ + public Float optFloatNullable(String key, Float defaultValue) { + Number val = this.optNumber(key); + if (val == null) { + return defaultValue; + } + final float floatValue = val.floatValue(); + // if (Float.isNaN(floatValue) || Float.isInfinite(floatValue)) { + // return defaultValue; + // } + return floatValue; + } + /** * Get an optional int value associated with a key, or zero if there is no * such key or if the value is not a number. If the value is a string, an @@ -1348,6 +1421,25 @@ public int optInt(String key, int defaultValue) { } return val.intValue(); } + + /** + * Get an optional int value associated with a key, or the default if there + * is no such key or if the value is not a number. If the value is a string, + * an attempt will be made to evaluate it as a number. + * + * @param key + * A key string. + * @param defaultValue + * The default. + * @return An object which is the value. including null + */ + public Integer optIntNullable(String key, Integer defaultValue) { + final Number val = this.optNumber(key, null); + if (val == null) { + return defaultValue; + } + return val.intValue(); + } /** * Get an optional JSONArray associated with a key. It returns null if there @@ -1407,6 +1499,26 @@ public long optLong(String key, long defaultValue) { return val.longValue(); } + + /** + * Get an optional long value associated with a key, or the default if there + * is no such key or if the value is not a number. If the value is a string, + * an attempt will be made to evaluate it as a number. + * + * @param key + * A key string. + * @param defaultValue + * The default. + * @return An object which is the value. including null + */ + public Long optLongNullable(String key, Long defaultValue) { + final Number val = this.optNumber(key, null); + if (val == null) { + return defaultValue; + } + + return val.longValue(); + } /** * Get an optional {@link Number} value associated with a key, or null @@ -2596,7 +2708,7 @@ public Writer write(Writer writer, int indentFactor, int indent) * @return a java.util.Map containing the entries of this object */ public Map toMap() { - Map results = new HashMap(); + Map results = new LinkedHashMap(); for (Entry entry : this.entrySet()) { Object value; if (entry.getValue() == null || NULL.equals(entry.getValue())) { diff --git a/src/main/java/org/json/JSONPointer.java b/src/com/github/tsohr/JSONPointer.java similarity index 99% rename from src/main/java/org/json/JSONPointer.java rename to src/com/github/tsohr/JSONPointer.java index a3d1c1a2a..17a36b1c3 100644 --- a/src/main/java/org/json/JSONPointer.java +++ b/src/com/github/tsohr/JSONPointer.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; import static java.lang.String.format; diff --git a/src/main/java/org/json/JSONPointerException.java b/src/com/github/tsohr/JSONPointerException.java similarity index 98% rename from src/main/java/org/json/JSONPointerException.java rename to src/com/github/tsohr/JSONPointerException.java index 0ce1aeb29..17155957f 100644 --- a/src/main/java/org/json/JSONPointerException.java +++ b/src/com/github/tsohr/JSONPointerException.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/JSONPropertyIgnore.java b/src/com/github/tsohr/JSONPropertyIgnore.java similarity index 98% rename from src/main/java/org/json/JSONPropertyIgnore.java rename to src/com/github/tsohr/JSONPropertyIgnore.java index 682de7447..63a44ae5b 100644 --- a/src/main/java/org/json/JSONPropertyIgnore.java +++ b/src/com/github/tsohr/JSONPropertyIgnore.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2018 JSON.org diff --git a/src/main/java/org/json/JSONPropertyName.java b/src/com/github/tsohr/JSONPropertyName.java similarity index 98% rename from src/main/java/org/json/JSONPropertyName.java rename to src/com/github/tsohr/JSONPropertyName.java index a1bcd58bf..24e1012ca 100644 --- a/src/main/java/org/json/JSONPropertyName.java +++ b/src/com/github/tsohr/JSONPropertyName.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2018 JSON.org diff --git a/src/main/java/org/json/JSONString.java b/src/com/github/tsohr/JSONString.java similarity index 98% rename from src/main/java/org/json/JSONString.java rename to src/com/github/tsohr/JSONString.java index bcd9a8128..7f4aa52ba 100644 --- a/src/main/java/org/json/JSONString.java +++ b/src/com/github/tsohr/JSONString.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/JSONStringer.java b/src/com/github/tsohr/JSONStringer.java similarity index 99% rename from src/main/java/org/json/JSONStringer.java rename to src/com/github/tsohr/JSONStringer.java index bb9e7a4cf..0f12c4683 100644 --- a/src/main/java/org/json/JSONStringer.java +++ b/src/com/github/tsohr/JSONStringer.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2006 JSON.org diff --git a/src/main/java/org/json/JSONTokener.java b/src/com/github/tsohr/JSONTokener.java similarity index 99% rename from src/main/java/org/json/JSONTokener.java rename to src/com/github/tsohr/JSONTokener.java index e6821de32..88d291ee7 100644 --- a/src/main/java/org/json/JSONTokener.java +++ b/src/com/github/tsohr/JSONTokener.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/main/java/org/json/JSONWriter.java b/src/com/github/tsohr/JSONWriter.java similarity index 99% rename from src/main/java/org/json/JSONWriter.java rename to src/com/github/tsohr/JSONWriter.java index dafb1b264..a2b1877b3 100644 --- a/src/main/java/org/json/JSONWriter.java +++ b/src/com/github/tsohr/JSONWriter.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; import java.io.IOException; import java.util.Collection; diff --git a/src/main/java/org/json/Property.java b/src/com/github/tsohr/Property.java similarity index 99% rename from src/main/java/org/json/Property.java rename to src/com/github/tsohr/Property.java index 7caeebb07..b633db5a8 100644 --- a/src/main/java/org/json/Property.java +++ b/src/com/github/tsohr/Property.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/XML.java b/src/com/github/tsohr/XML.java similarity index 99% rename from src/main/java/org/json/XML.java rename to src/com/github/tsohr/XML.java index 805a5c376..3b59140d3 100644 --- a/src/main/java/org/json/XML.java +++ b/src/com/github/tsohr/XML.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2015 JSON.org diff --git a/src/main/java/org/json/XMLParserConfiguration.java b/src/com/github/tsohr/XMLParserConfiguration.java similarity index 97% rename from src/main/java/org/json/XMLParserConfiguration.java rename to src/com/github/tsohr/XMLParserConfiguration.java index b9e752c28..e41e39115 100644 --- a/src/main/java/org/json/XMLParserConfiguration.java +++ b/src/com/github/tsohr/XMLParserConfiguration.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org @@ -24,7 +24,7 @@ of this software and associated documentation files (the "Software"), to deal */ import java.util.Collections; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; @@ -149,7 +149,7 @@ public XMLParserConfiguration (final boolean keepStrings, final String cDataTagN * to use that value as the JSONObject key name to process as CDATA. * @param convertNilAttributeToNull true to parse values with attribute xsi:nil="true" as null. * false to parse values with attribute xsi:nil="true" as {"xsi:nil":true}. - * @param xsiTypeMap new HashMap>() to parse values with attribute + * @param xsiTypeMap new LinkedHashMap>() to parse values with attribute * xsi:type="integer" as integer, xsi:type="string" as string */ private XMLParserConfiguration (final boolean keepStrings, final String cDataTagName, @@ -273,13 +273,13 @@ public Map> getXsiTypeMap() { * will be converted to target type defined to client in this configuration * {@code Map>} to parse values with attribute * xsi:type="integer" as integer, xsi:type="string" as string - * @param xsiTypeMap {@code new HashMap>()} to parse values with attribute + * @param xsiTypeMap {@code new LinkedHashMap>()} to parse values with attribute * xsi:type="integer" as integer, xsi:type="string" as string * @return The existing configuration will not be modified. A new configuration is returned. */ public XMLParserConfiguration withXsiTypeMap(final Map> xsiTypeMap) { XMLParserConfiguration newConfig = this.clone(); - Map> cloneXsiTypeMap = new HashMap>(xsiTypeMap); + Map> cloneXsiTypeMap = new LinkedHashMap>(xsiTypeMap); newConfig.xsiTypeMap = Collections.unmodifiableMap(cloneXsiTypeMap); return newConfig; } diff --git a/src/main/java/org/json/XMLTokener.java b/src/com/github/tsohr/XMLTokener.java similarity index 99% rename from src/main/java/org/json/XMLTokener.java rename to src/com/github/tsohr/XMLTokener.java index 3bbd3824b..6e40812f4 100644 --- a/src/main/java/org/json/XMLTokener.java +++ b/src/com/github/tsohr/XMLTokener.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/src/main/java/org/json/XMLXsiTypeConverter.java b/src/com/github/tsohr/XMLXsiTypeConverter.java similarity index 93% rename from src/main/java/org/json/XMLXsiTypeConverter.java rename to src/com/github/tsohr/XMLXsiTypeConverter.java index 0f8a8c332..fab57de57 100644 --- a/src/main/java/org/json/XMLXsiTypeConverter.java +++ b/src/com/github/tsohr/XMLXsiTypeConverter.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org @@ -45,7 +45,7 @@ of this software and associated documentation files (the "Software"), to deal * * Usage * {@code - * Map> xsiTypeMap = new HashMap>(); + * Map> xsiTypeMap = new LinkedHashMap>(); * xsiTypeMap.put("string", new XMLXsiTypeConverter() { * @Override public String convert(final String value) { * return value; diff --git a/src/test/java/org/json/junit/CDLTest.java b/test/com/github/tsohr/junit/CDLTest.java similarity index 98% rename from src/test/java/org/json/junit/CDLTest.java rename to test/com/github/tsohr/junit/CDLTest.java index 48586b741..b82c4e226 100644 --- a/src/test/java/org/json/junit/CDLTest.java +++ b/test/com/github/tsohr/junit/CDLTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -27,10 +27,10 @@ of this software and associated documentation files (the "Software"), to deal import static org.junit.Assert.*; import org.junit.Test; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONArray; -import org.json.CDL; +import com.github.tsohr.JSONException; +import com.github.tsohr.JSONObject; +import com.github.tsohr.JSONArray; +import com.github.tsohr.CDL; /** * Tests for CDL.java. diff --git a/src/test/java/org/json/junit/CookieListTest.java b/test/com/github/tsohr/junit/CookieListTest.java similarity index 99% rename from src/test/java/org/json/junit/CookieListTest.java rename to test/com/github/tsohr/junit/CookieListTest.java index c3f647f90..c61bf8525 100644 --- a/src/test/java/org/json/junit/CookieListTest.java +++ b/test/com/github/tsohr/junit/CookieListTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -28,7 +28,7 @@ of this software and associated documentation files (the "Software"), to deal import java.util.*; -import org.json.*; +import com.github.tsohr.*; import org.junit.Test; import com.jayway.jsonpath.*; diff --git a/src/test/java/org/json/junit/CookieTest.java b/test/com/github/tsohr/junit/CookieTest.java similarity index 99% rename from src/test/java/org/json/junit/CookieTest.java rename to test/com/github/tsohr/junit/CookieTest.java index 7e7b62b45..7ec9966ef 100644 --- a/src/test/java/org/json/junit/CookieTest.java +++ b/test/com/github/tsohr/junit/CookieTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -26,7 +26,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.junit.Assert.*; -import org.json.*; +import com.github.tsohr.*; import org.junit.Test; diff --git a/src/test/java/org/json/junit/EnumTest.java b/test/com/github/tsohr/junit/EnumTest.java similarity index 98% rename from src/test/java/org/json/junit/EnumTest.java rename to test/com/github/tsohr/junit/EnumTest.java index ed2c87a6b..843c0461b 100644 --- a/src/test/java/org/json/junit/EnumTest.java +++ b/test/com/github/tsohr/junit/EnumTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -32,11 +32,11 @@ of this software and associated documentation files (the "Software"), to deal import java.util.List; import java.util.Map; -import org.json.JSONArray; -import org.json.JSONObject; -import org.json.junit.data.MyEnum; -import org.json.junit.data.MyEnumClass; -import org.json.junit.data.MyEnumField; +import com.github.tsohr.JSONArray; +import com.github.tsohr.JSONObject; +import com.github.tsohr.junit.data.MyEnum; +import com.github.tsohr.junit.data.MyEnumClass; +import com.github.tsohr.junit.data.MyEnumField; import org.junit.Test; import com.jayway.jsonpath.Configuration; @@ -222,7 +222,7 @@ public void enumValueToString() { * However, an enum within another class will not be rendered * unless that class overrides default toString() */ - String expectedStr3 = "\"org.json.junit.data.MyEnumClass@"; + String expectedStr3 = "\"com.github.tsohr.junit.data.MyEnumClass@"; myEnumClass.setMyEnum(MyEnum.VAL1); myEnumClass.setMyEnumField(MyEnumField.VAL1); String str3 = JSONObject.valueToString(myEnumClass); diff --git a/src/test/java/org/json/junit/HTTPTest.java b/test/com/github/tsohr/junit/HTTPTest.java similarity index 99% rename from src/test/java/org/json/junit/HTTPTest.java rename to test/com/github/tsohr/junit/HTTPTest.java index 8182b6059..e0d6e5c35 100644 --- a/src/test/java/org/json/junit/HTTPTest.java +++ b/test/com/github/tsohr/junit/HTTPTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -26,7 +26,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.junit.Assert.*; -import org.json.*; +import com.github.tsohr.*; import org.junit.Test; diff --git a/src/test/java/org/json/junit/JSONArrayTest.java b/test/com/github/tsohr/junit/JSONArrayTest.java similarity index 99% rename from src/test/java/org/json/junit/JSONArrayTest.java rename to test/com/github/tsohr/junit/JSONArrayTest.java index 1c042516f..890e20905 100644 --- a/src/test/java/org/json/junit/JSONArrayTest.java +++ b/test/com/github/tsohr/junit/JSONArrayTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -38,17 +38,17 @@ of this software and associated documentation files (the "Software"), to deal import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONPointerException; import org.junit.Test; +import com.github.tsohr.JSONArray; +import com.github.tsohr.JSONException; +import com.github.tsohr.JSONObject; +import com.github.tsohr.JSONPointerException; import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.JsonPath; @@ -629,7 +629,7 @@ public void put() { // 7 jsonArray.put(jsonObject); - Map map = new HashMap(); + Map map = new LinkedHashMap(); map.put("k1", "v1"); // 8 jsonArray.put(map); @@ -710,7 +710,7 @@ public void putIndex() { collection.add(2); jsonArray.put(9,collection); - Map map = new HashMap(); + Map map = new LinkedHashMap(); map.put("k1", "v1"); jsonArray.put(10, map); try { @@ -1267,6 +1267,6 @@ public void jsonArrayClearMethodTest() { jsonArray.put(new JSONArray()); jsonArray.clear(); //Clears the JSONArray assertTrue("expected jsonArray.length() == 0", jsonArray.length() == 0); //Check if its length is 0 - jsonArray.getInt(0); //Should throws org.json.JSONException: JSONArray[0] not found + jsonArray.getInt(0); //Should throws com.github.tsohr.JSONException: JSONArray[0] not found } } diff --git a/src/test/java/org/json/junit/JSONMLTest.java b/test/com/github/tsohr/junit/JSONMLTest.java similarity index 99% rename from src/test/java/org/json/junit/JSONMLTest.java rename to test/com/github/tsohr/junit/JSONMLTest.java index 8f3de42cf..787a9e867 100644 --- a/src/test/java/org/json/junit/JSONMLTest.java +++ b/test/com/github/tsohr/junit/JSONMLTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -26,11 +26,11 @@ of this software and associated documentation files (the "Software"), to deal import static org.junit.Assert.*; -import org.json.*; +import com.github.tsohr.*; import org.junit.Test; /** - * Tests for org.json.JSONML.java + * Tests for com.github.tsohr.JSONML.java * * Certain inputs are expected to result in exceptions. These tests are * executed first. JSONML provides an API to: diff --git a/src/test/java/org/json/junit/JSONObjectLocaleTest.java b/test/com/github/tsohr/junit/JSONObjectLocaleTest.java old mode 100755 new mode 100644 similarity index 96% rename from src/test/java/org/json/junit/JSONObjectLocaleTest.java rename to test/com/github/tsohr/junit/JSONObjectLocaleTest.java index 5112bf56e..3c7bd0b6f --- a/src/test/java/org/json/junit/JSONObjectLocaleTest.java +++ b/test/com/github/tsohr/junit/JSONObjectLocaleTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -28,8 +28,8 @@ of this software and associated documentation files (the "Software"), to deal import java.util.*; -import org.json.*; -import org.json.junit.data.MyLocaleBean; +import com.github.tsohr.*; +import com.github.tsohr.junit.data.MyLocaleBean; import org.junit.*; /** diff --git a/src/test/java/org/json/junit/JSONObjectTest.java b/test/com/github/tsohr/junit/JSONObjectTest.java similarity index 98% rename from src/test/java/org/json/junit/JSONObjectTest.java rename to test/com/github/tsohr/junit/JSONObjectTest.java index 2e296f071..65a9ea34e 100644 --- a/src/test/java/org/json/junit/JSONObjectTest.java +++ b/test/com/github/tsohr/junit/JSONObjectTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -44,40 +44,40 @@ of this software and associated documentation files (the "Software"), to deal import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Pattern; -import org.json.CDL; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONPointerException; -import org.json.JSONTokener; -import org.json.XML; -import org.json.junit.data.BrokenToString; -import org.json.junit.data.ExceptionalBean; -import org.json.junit.data.Fraction; -import org.json.junit.data.GenericBean; -import org.json.junit.data.GenericBeanInt; -import org.json.junit.data.MyBean; -import org.json.junit.data.MyBeanCustomName; -import org.json.junit.data.MyBeanCustomNameSubClass; -import org.json.junit.data.MyBigNumberBean; -import org.json.junit.data.MyEnum; -import org.json.junit.data.MyEnumField; -import org.json.junit.data.MyJsonString; -import org.json.junit.data.MyNumber; -import org.json.junit.data.MyNumberContainer; -import org.json.junit.data.MyPublicClass; -import org.json.junit.data.Singleton; -import org.json.junit.data.SingletonEnum; -import org.json.junit.data.WeirdList; import org.junit.Test; +import com.github.tsohr.CDL; +import com.github.tsohr.JSONArray; +import com.github.tsohr.JSONException; +import com.github.tsohr.JSONObject; +import com.github.tsohr.JSONPointerException; +import com.github.tsohr.JSONTokener; +import com.github.tsohr.XML; +import com.github.tsohr.junit.data.BrokenToString; +import com.github.tsohr.junit.data.ExceptionalBean; +import com.github.tsohr.junit.data.Fraction; +import com.github.tsohr.junit.data.GenericBean; +import com.github.tsohr.junit.data.GenericBeanInt; +import com.github.tsohr.junit.data.MyBean; +import com.github.tsohr.junit.data.MyBeanCustomName; +import com.github.tsohr.junit.data.MyBeanCustomNameSubClass; +import com.github.tsohr.junit.data.MyBigNumberBean; +import com.github.tsohr.junit.data.MyEnum; +import com.github.tsohr.junit.data.MyEnumField; +import com.github.tsohr.junit.data.MyJsonString; +import com.github.tsohr.junit.data.MyNumber; +import com.github.tsohr.junit.data.MyNumberContainer; +import com.github.tsohr.junit.data.MyPublicClass; +import com.github.tsohr.junit.data.Singleton; +import com.github.tsohr.junit.data.SingletonEnum; +import com.github.tsohr.junit.data.WeirdList; import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.JsonPath; @@ -298,7 +298,7 @@ public void jsonObjectByNullMap() { */ @Test public void jsonObjectByMap() { - Map map = new HashMap(); + Map map = new LinkedHashMap(); map.put("trueKey", new Boolean(true)); map.put("falseKey", new Boolean(false)); map.put("stringKey", "hello world!"); @@ -527,7 +527,7 @@ public void verifyPutMap() { */ @Test public void jsonObjectByMapWithUnsupportedValues() { - Map jsonMap = new HashMap(); + Map jsonMap = new LinkedHashMap(); // Just insert some random objects jsonMap.put("key1", new CDL()); jsonMap.put("key2", new Exception()); @@ -547,7 +547,7 @@ public void jsonObjectByMapWithUnsupportedValues() { */ @Test public void jsonObjectByMapWithNullValue() { - Map map = new HashMap(); + Map map = new LinkedHashMap(); map.put("trueKey", new Boolean(true)); map.put("falseKey", new Boolean(false)); map.put("stringKey", "hello world!"); @@ -720,7 +720,7 @@ public void jsonObjectByObjectAndNames() { @Test public void jsonObjectByResourceBundle() { JSONObject jsonObject = new - JSONObject("org.json.junit.data.StringsResourceBundle", + JSONObject("com.github.tsohr.junit.data.StringsResourceBundle", Locale.getDefault()); // validate JSON @@ -1329,7 +1329,7 @@ public void bigNumberOperations() { * wrap() vs put() big number behavior is now the same. */ // bigInt map ctor - Map map = new HashMap(); + Map map = new LinkedHashMap(); map.put("bigInt", bigInteger); jsonObject = new JSONObject(map); String actualFromMapStr = jsonObject.toString(); @@ -1344,7 +1344,7 @@ public void bigNumberOperations() { actualFromPutStr.equals( "{\"bigInt\":123456789012345678901234567890}")); // bigDec map ctor - map = new HashMap(); + map = new LinkedHashMap(); map.put("bigDec", bigDecimal); jsonObject = new JSONObject(map); actualFromMapStr = jsonObject.toString(); @@ -1717,7 +1717,7 @@ public void jsonObjectPut() { jsonObject.put("falseKey", false); Integer [] intArray = { 0, 1, 2 }; jsonObject.put("arrayKey", Arrays.asList(intArray)); - Map myMap = new HashMap(); + Map myMap = new LinkedHashMap(); myMap.put("myKey1", "myVal1"); myMap.put("myKey2", "myVal2"); myMap.put("myKey3", "myVal3"); @@ -1886,7 +1886,7 @@ public void jsonObjectToStringIndent() { @Test public void jsonObjectToStringSuppressWarningOnCastToMap() { JSONObject jsonObject = new JSONObject(); - Map map = new HashMap(); + Map map = new LinkedHashMap(); map.put("abc", "def"); jsonObject.put("key", map); @@ -1948,7 +1948,7 @@ public void valueToString() { JSONArray jsonArray = new JSONArray(jsonArrayStr); assertTrue("jsonArray valueToString() incorrect", JSONObject.valueToString(jsonArray).equals(jsonArray.toString())); - Map map = new HashMap(); + Map map = new LinkedHashMap(); map.put("key1", "val1"); map.put("key2", "val2"); map.put("key3", "val3"); @@ -1975,7 +1975,7 @@ public void valueToString() { @SuppressWarnings("boxing") @Test public void valueToStringConfirmException() { - Map myMap = new HashMap(); + Map myMap = new LinkedHashMap(); myMap.put(1, "myValue"); // this is the test, it should not throw an exception String str = JSONObject.valueToString(myMap); @@ -2056,7 +2056,7 @@ public void wrapObject() { assertTrue("expected 3", Integer.valueOf(3).equals(jsonArray.query("/2"))); // wrap map returns JSONObject - Map map = new HashMap(); + Map map = new LinkedHashMap(); map.put("key1", "val1"); map.put("key2", "val2"); map.put("key3", "val3"); @@ -3228,6 +3228,6 @@ public void jsonObjectClearMethodTest() { jsonObject.put("key3", new JSONObject()); jsonObject.clear(); //Clears the JSONObject assertTrue("expected jsonObject.length() == 0", jsonObject.length() == 0); //Check if its length is 0 - jsonObject.getInt("key1"); //Should throws org.json.JSONException: JSONObject["asd"] not found + jsonObject.getInt("key1"); //Should throws com.github.tsohr.JSONException: JSONObject["asd"] not found } } diff --git a/src/test/java/org/json/junit/JSONPointerTest.java b/test/com/github/tsohr/junit/JSONPointerTest.java similarity index 98% rename from src/test/java/org/json/junit/JSONPointerTest.java rename to test/com/github/tsohr/junit/JSONPointerTest.java index f1b96849c..b838805de 100644 --- a/src/test/java/org/json/junit/JSONPointerTest.java +++ b/test/com/github/tsohr/junit/JSONPointerTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -31,11 +31,11 @@ of this software and associated documentation files (the "Software"), to deal import java.io.InputStream; -import org.json.JSONArray; -import org.json.JSONObject; -import org.json.JSONPointer; -import org.json.JSONPointerException; -import org.json.JSONTokener; +import com.github.tsohr.JSONArray; +import com.github.tsohr.JSONObject; +import com.github.tsohr.JSONPointer; +import com.github.tsohr.JSONPointerException; +import com.github.tsohr.JSONTokener; import org.junit.Test; public class JSONPointerTest { diff --git a/src/test/java/org/json/junit/JSONStringTest.java b/test/com/github/tsohr/junit/JSONStringTest.java similarity index 99% rename from src/test/java/org/json/junit/JSONStringTest.java rename to test/com/github/tsohr/junit/JSONStringTest.java index a19961103..6b0c4fed7 100644 --- a/src/test/java/org/json/junit/JSONStringTest.java +++ b/test/com/github/tsohr/junit/JSONStringTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -29,7 +29,7 @@ of this software and associated documentation files (the "Software"), to deal import java.io.StringWriter; import java.util.*; -import org.json.*; +import com.github.tsohr.*; import org.junit.Test; /** diff --git a/src/test/java/org/json/junit/JSONStringerTest.java b/test/com/github/tsohr/junit/JSONStringerTest.java similarity index 99% rename from src/test/java/org/json/junit/JSONStringerTest.java rename to test/com/github/tsohr/junit/JSONStringerTest.java index a99db3b8c..ba0a40566 100644 --- a/src/test/java/org/json/junit/JSONStringerTest.java +++ b/test/com/github/tsohr/junit/JSONStringerTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -29,7 +29,7 @@ of this software and associated documentation files (the "Software"), to deal import java.math.BigDecimal; import java.util.*; -import org.json.*; +import com.github.tsohr.*; import org.junit.Test; import com.jayway.jsonpath.*; diff --git a/src/test/java/org/json/junit/JSONTokenerTest.java b/test/com/github/tsohr/junit/JSONTokenerTest.java similarity index 98% rename from src/test/java/org/json/junit/JSONTokenerTest.java rename to test/com/github/tsohr/junit/JSONTokenerTest.java index e8e0f98a9..7dd1c14e0 100644 --- a/src/test/java/org/json/junit/JSONTokenerTest.java +++ b/test/com/github/tsohr/junit/JSONTokenerTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -36,14 +36,14 @@ of this software and associated documentation files (the "Software"), to deal import java.io.Reader; import java.io.StringReader; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; +import com.github.tsohr.JSONArray; +import com.github.tsohr.JSONException; +import com.github.tsohr.JSONObject; +import com.github.tsohr.JSONTokener; import org.junit.Test; /** - * Test specific to the {@link org.json.JSONTokener} class. + * Test specific to the {@link com.github.tsohr.JSONTokener} class. * @author John Aylward * */ diff --git a/src/test/java/org/json/junit/PropertyTest.java b/test/com/github/tsohr/junit/PropertyTest.java similarity index 98% rename from src/test/java/org/json/junit/PropertyTest.java rename to test/com/github/tsohr/junit/PropertyTest.java index e1a9b8dcf..60390a21d 100644 --- a/src/test/java/org/json/junit/PropertyTest.java +++ b/test/com/github/tsohr/junit/PropertyTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -28,7 +28,7 @@ of this software and associated documentation files (the "Software"), to deal import static org.junit.Assert.*; -import org.json.*; +import com.github.tsohr.*; import org.junit.Test; diff --git a/src/test/java/org/json/junit/Util.java b/test/com/github/tsohr/junit/Util.java similarity index 98% rename from src/test/java/org/json/junit/Util.java rename to test/com/github/tsohr/junit/Util.java index 8dc27ddfa..a8784d4b6 100644 --- a/src/test/java/org/json/junit/Util.java +++ b/test/com/github/tsohr/junit/Util.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -28,7 +28,7 @@ of this software and associated documentation files (the "Software"), to deal import java.util.*; -import org.json.*; +import com.github.tsohr.*; /** * These are helpful utility methods that perform basic comparisons diff --git a/src/test/java/org/json/junit/XMLConfigurationTest.java b/test/com/github/tsohr/junit/XMLConfigurationTest.java old mode 100755 new mode 100644 similarity index 99% rename from src/test/java/org/json/junit/XMLConfigurationTest.java rename to test/com/github/tsohr/junit/XMLConfigurationTest.java index 28b20ddfd..2317e563a --- a/src/test/java/org/json/junit/XMLConfigurationTest.java +++ b/test/com/github/tsohr/junit/XMLConfigurationTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -36,11 +36,11 @@ of this software and associated documentation files (the "Software"), to deal import java.io.Reader; import java.io.StringReader; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.XML; -import org.json.XMLParserConfiguration; +import com.github.tsohr.JSONArray; +import com.github.tsohr.JSONException; +import com.github.tsohr.JSONObject; +import com.github.tsohr.XML; +import com.github.tsohr.XMLParserConfiguration; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; diff --git a/src/test/java/org/json/junit/XMLTest.java b/test/com/github/tsohr/junit/XMLTest.java similarity index 98% rename from src/test/java/org/json/junit/XMLTest.java rename to test/com/github/tsohr/junit/XMLTest.java index 62ee516b2..33167b123 100644 --- a/src/test/java/org/json/junit/XMLTest.java +++ b/test/com/github/tsohr/junit/XMLTest.java @@ -1,4 +1,4 @@ -package org.json.junit; +package com.github.tsohr.junit; /* Copyright (c) 2020 JSON.org @@ -38,20 +38,21 @@ of this software and associated documentation files (the "Software"), to deal import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.json.JSONTokener; -import org.json.XML; -import org.json.XMLParserConfiguration; -import org.json.XMLXsiTypeConverter; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; +import com.github.tsohr.JSONArray; +import com.github.tsohr.JSONException; +import com.github.tsohr.JSONObject; +import com.github.tsohr.JSONTokener; +import com.github.tsohr.XML; +import com.github.tsohr.XMLParserConfiguration; +import com.github.tsohr.XMLXsiTypeConverter; + /** * Tests for JSON-Java XML.java @@ -997,7 +998,7 @@ public void testToJsonWithTypeWhenTypeConversionEnabled() { + "1234"; String expectedJsonString = "{\"root\":{\"id2\":1234,\"id1\":\"1234\"}}"; JSONObject expectedJson = new JSONObject(expectedJsonString); - Map> xsiTypeMap = new HashMap>(); + Map> xsiTypeMap = new LinkedHashMap>(); xsiTypeMap.put("string", new XMLXsiTypeConverter() { @Override public String convert(final String value) { return value; @@ -1018,7 +1019,7 @@ public void testToJsonWithXSITypeWhenTypeConversionEnabled() { + "xsi:type=\"integer\">54321"; String expectedJsonString = "{\"root\":{\"asString\":\"12345\",\"asInt\":54321}}"; JSONObject expectedJson = new JSONObject(expectedJsonString); - Map> xsiTypeMap = new HashMap>(); + Map> xsiTypeMap = new LinkedHashMap>(); xsiTypeMap.put("string", new XMLXsiTypeConverter() { @Override public String convert(final String value) { return value; @@ -1038,7 +1039,7 @@ public void testToJsonWithXSITypeWhenTypeConversionNotEnabledOnOne() { String originalXml = "1234554321"; String expectedJsonString = "{\"root\":{\"asString\":\"12345\",\"asInt\":54321}}"; JSONObject expectedJson = new JSONObject(expectedJsonString); - Map> xsiTypeMap = new HashMap>(); + Map> xsiTypeMap = new LinkedHashMap>(); xsiTypeMap.put("string", new XMLXsiTypeConverter() { @Override public String convert(final String value) { return value; @@ -1050,7 +1051,7 @@ public void testToJsonWithXSITypeWhenTypeConversionNotEnabledOnOne() { @Test public void testXSITypeMapNotModifiable() { - Map> xsiTypeMap = new HashMap>(); + Map> xsiTypeMap = new LinkedHashMap>(); XMLParserConfiguration config = new XMLParserConfiguration().withXsiTypeMap(xsiTypeMap); xsiTypeMap.put("string", new XMLXsiTypeConverter() { @Override public String convert(final String value) { diff --git a/src/test/java/org/json/junit/data/BrokenToString.java b/test/com/github/tsohr/junit/data/BrokenToString.java similarity index 86% rename from src/test/java/org/json/junit/data/BrokenToString.java rename to test/com/github/tsohr/junit/data/BrokenToString.java index 585d7518a..aadeb3a89 100644 --- a/src/test/java/org/json/junit/data/BrokenToString.java +++ b/test/com/github/tsohr/junit/data/BrokenToString.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; /** * test class for verifying write errors. diff --git a/src/test/java/org/json/junit/data/ExceptionalBean.java b/test/com/github/tsohr/junit/data/ExceptionalBean.java similarity index 97% rename from src/test/java/org/json/junit/data/ExceptionalBean.java rename to test/com/github/tsohr/junit/data/ExceptionalBean.java index 72d6c0cdb..d034aea4b 100644 --- a/src/test/java/org/json/junit/data/ExceptionalBean.java +++ b/test/com/github/tsohr/junit/data/ExceptionalBean.java @@ -1,7 +1,7 @@ /** * */ -package org.json.junit.data; +package com.github.tsohr.junit.data; import java.io.Closeable; import java.io.IOException; diff --git a/src/test/java/org/json/junit/data/Fraction.java b/test/com/github/tsohr/junit/data/Fraction.java similarity index 99% rename from src/test/java/org/json/junit/data/Fraction.java rename to test/com/github/tsohr/junit/data/Fraction.java index c418179f9..0268409ee 100644 --- a/src/test/java/org/json/junit/data/Fraction.java +++ b/test/com/github/tsohr/junit/data/Fraction.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; import java.math.BigDecimal; import java.math.BigInteger; diff --git a/src/test/java/org/json/junit/data/GenericBean.java b/test/com/github/tsohr/junit/data/GenericBean.java similarity index 97% rename from src/test/java/org/json/junit/data/GenericBean.java rename to test/com/github/tsohr/junit/data/GenericBean.java index da6370d48..96a5b0332 100644 --- a/src/test/java/org/json/junit/data/GenericBean.java +++ b/test/com/github/tsohr/junit/data/GenericBean.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; import java.io.StringReader; diff --git a/src/test/java/org/json/junit/data/GenericBeanInt.java b/test/com/github/tsohr/junit/data/GenericBeanInt.java similarity index 96% rename from src/test/java/org/json/junit/data/GenericBeanInt.java rename to test/com/github/tsohr/junit/data/GenericBeanInt.java index 505661162..a318a8383 100644 --- a/src/test/java/org/json/junit/data/GenericBeanInt.java +++ b/test/com/github/tsohr/junit/data/GenericBeanInt.java @@ -1,7 +1,7 @@ /** * */ -package org.json.junit.data; +package com.github.tsohr.junit.data; /** * @author john diff --git a/src/test/java/org/json/junit/data/MyBean.java b/test/com/github/tsohr/junit/data/MyBean.java similarity index 90% rename from src/test/java/org/json/junit/data/MyBean.java rename to test/com/github/tsohr/junit/data/MyBean.java index 31909810f..e37478f14 100644 --- a/src/test/java/org/json/junit/data/MyBean.java +++ b/test/com/github/tsohr/junit/data/MyBean.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; import java.io.*; diff --git a/src/test/java/org/json/junit/data/MyBeanCustomName.java b/test/com/github/tsohr/junit/data/MyBeanCustomName.java similarity index 88% rename from src/test/java/org/json/junit/data/MyBeanCustomName.java rename to test/com/github/tsohr/junit/data/MyBeanCustomName.java index 56756c2b3..217753549 100644 --- a/src/test/java/org/json/junit/data/MyBeanCustomName.java +++ b/test/com/github/tsohr/junit/data/MyBeanCustomName.java @@ -1,6 +1,6 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; -import org.json.JSONPropertyName; +import com.github.tsohr.JSONPropertyName; /** * Test bean for the {@link JSONPropertyName} annotation. diff --git a/src/test/java/org/json/junit/data/MyBeanCustomNameInterface.java b/test/com/github/tsohr/junit/data/MyBeanCustomNameInterface.java similarity index 56% rename from src/test/java/org/json/junit/data/MyBeanCustomNameInterface.java rename to test/com/github/tsohr/junit/data/MyBeanCustomNameInterface.java index b25b57873..5ebfce806 100644 --- a/src/test/java/org/json/junit/data/MyBeanCustomNameInterface.java +++ b/test/com/github/tsohr/junit/data/MyBeanCustomNameInterface.java @@ -1,7 +1,7 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; -import org.json.JSONPropertyIgnore; -import org.json.JSONPropertyName; +import com.github.tsohr.JSONPropertyIgnore; +import com.github.tsohr.JSONPropertyName; public interface MyBeanCustomNameInterface { @JSONPropertyName("InterfaceField") diff --git a/src/test/java/org/json/junit/data/MyBeanCustomNameSubClass.java b/test/com/github/tsohr/junit/data/MyBeanCustomNameSubClass.java similarity index 78% rename from src/test/java/org/json/junit/data/MyBeanCustomNameSubClass.java rename to test/com/github/tsohr/junit/data/MyBeanCustomNameSubClass.java index 8f0500cce..d4740e638 100644 --- a/src/test/java/org/json/junit/data/MyBeanCustomNameSubClass.java +++ b/test/com/github/tsohr/junit/data/MyBeanCustomNameSubClass.java @@ -1,13 +1,13 @@ /** * */ -package org.json.junit.data; +package com.github.tsohr.junit.data; -import org.json.JSONPropertyIgnore; -import org.json.JSONPropertyName; +import com.github.tsohr.JSONPropertyIgnore; +import com.github.tsohr.JSONPropertyName; /** - * Test bean to verify that the {@link org.json.JSONPropertyName} annotation + * Test bean to verify that the {@link com.github.tsohr.JSONPropertyName} annotation * is inherited. */ public class MyBeanCustomNameSubClass extends MyBeanCustomName { diff --git a/src/test/java/org/json/junit/data/MyBigNumberBean.java b/test/com/github/tsohr/junit/data/MyBigNumberBean.java similarity index 84% rename from src/test/java/org/json/junit/data/MyBigNumberBean.java rename to test/com/github/tsohr/junit/data/MyBigNumberBean.java index 934dfee03..2a13fdf6a 100644 --- a/src/test/java/org/json/junit/data/MyBigNumberBean.java +++ b/test/com/github/tsohr/junit/data/MyBigNumberBean.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; import java.math.*; diff --git a/src/test/java/org/json/junit/data/MyEnum.java b/test/com/github/tsohr/junit/data/MyEnum.java similarity index 72% rename from src/test/java/org/json/junit/data/MyEnum.java rename to test/com/github/tsohr/junit/data/MyEnum.java index 50d9a4faa..50c73540e 100644 --- a/src/test/java/org/json/junit/data/MyEnum.java +++ b/test/com/github/tsohr/junit/data/MyEnum.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; /** * An enum with no methods or data diff --git a/src/test/java/org/json/junit/data/MyEnumClass.java b/test/com/github/tsohr/junit/data/MyEnumClass.java similarity index 93% rename from src/test/java/org/json/junit/data/MyEnumClass.java rename to test/com/github/tsohr/junit/data/MyEnumClass.java index 048669410..397350990 100644 --- a/src/test/java/org/json/junit/data/MyEnumClass.java +++ b/test/com/github/tsohr/junit/data/MyEnumClass.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; /** * this is simply a class that contains some enum instances diff --git a/src/test/java/org/json/junit/data/MyEnumField.java b/test/com/github/tsohr/junit/data/MyEnumField.java similarity index 93% rename from src/test/java/org/json/junit/data/MyEnumField.java rename to test/com/github/tsohr/junit/data/MyEnumField.java index 60e89de23..a6a99ec2e 100644 --- a/src/test/java/org/json/junit/data/MyEnumField.java +++ b/test/com/github/tsohr/junit/data/MyEnumField.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; /** * An enum that contains getters and some internal fields diff --git a/src/test/java/org/json/junit/data/MyJsonString.java b/test/com/github/tsohr/junit/data/MyJsonString.java similarity index 75% rename from src/test/java/org/json/junit/data/MyJsonString.java rename to test/com/github/tsohr/junit/data/MyJsonString.java index 4ddde5385..e067bdde6 100644 --- a/src/test/java/org/json/junit/data/MyJsonString.java +++ b/test/com/github/tsohr/junit/data/MyJsonString.java @@ -1,6 +1,6 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; -import org.json.*; +import com.github.tsohr.*; /** * Used in testing when a JSONString is needed diff --git a/src/test/java/org/json/junit/data/MyLocaleBean.java b/test/com/github/tsohr/junit/data/MyLocaleBean.java old mode 100755 new mode 100644 similarity index 85% rename from src/test/java/org/json/junit/data/MyLocaleBean.java rename to test/com/github/tsohr/junit/data/MyLocaleBean.java index 5d3cb5297..51daf6f76 --- a/src/test/java/org/json/junit/data/MyLocaleBean.java +++ b/test/com/github/tsohr/junit/data/MyLocaleBean.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; public class MyLocaleBean { private final String id = "beanId"; diff --git a/src/test/java/org/json/junit/data/MyNumber.java b/test/com/github/tsohr/junit/data/MyNumber.java similarity index 98% rename from src/test/java/org/json/junit/data/MyNumber.java rename to test/com/github/tsohr/junit/data/MyNumber.java index 4b625affc..2440fadbb 100644 --- a/src/test/java/org/json/junit/data/MyNumber.java +++ b/test/com/github/tsohr/junit/data/MyNumber.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; import java.math.BigDecimal; diff --git a/src/test/java/org/json/junit/data/MyNumberContainer.java b/test/com/github/tsohr/junit/data/MyNumberContainer.java similarity index 88% rename from src/test/java/org/json/junit/data/MyNumberContainer.java rename to test/com/github/tsohr/junit/data/MyNumberContainer.java index 65276529b..d83a01025 100644 --- a/src/test/java/org/json/junit/data/MyNumberContainer.java +++ b/test/com/github/tsohr/junit/data/MyNumberContainer.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; /** * Class that holds our MyNumber override as a property. diff --git a/src/test/java/org/json/junit/data/MyPublicClass.java b/test/com/github/tsohr/junit/data/MyPublicClass.java similarity index 84% rename from src/test/java/org/json/junit/data/MyPublicClass.java rename to test/com/github/tsohr/junit/data/MyPublicClass.java index 1f303860c..725f71586 100644 --- a/src/test/java/org/json/junit/data/MyPublicClass.java +++ b/test/com/github/tsohr/junit/data/MyPublicClass.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; /** * Need a class with some public data members for testing diff --git a/src/test/java/org/json/junit/data/Singleton.java b/test/com/github/tsohr/junit/data/Singleton.java similarity index 98% rename from src/test/java/org/json/junit/data/Singleton.java rename to test/com/github/tsohr/junit/data/Singleton.java index 224b48a5c..685fad149 100644 --- a/src/test/java/org/json/junit/data/Singleton.java +++ b/test/com/github/tsohr/junit/data/Singleton.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; /** * Sample singleton for use with bean testing. diff --git a/src/test/java/org/json/junit/data/SingletonEnum.java b/test/com/github/tsohr/junit/data/SingletonEnum.java similarity index 96% rename from src/test/java/org/json/junit/data/SingletonEnum.java rename to test/com/github/tsohr/junit/data/SingletonEnum.java index 3dd030939..5e377cf61 100644 --- a/src/test/java/org/json/junit/data/SingletonEnum.java +++ b/test/com/github/tsohr/junit/data/SingletonEnum.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; /** * Sample singleton done as an Enum for use with bean testing. diff --git a/src/test/java/org/json/junit/data/StringsResourceBundle.java b/test/com/github/tsohr/junit/data/StringsResourceBundle.java similarity index 91% rename from src/test/java/org/json/junit/data/StringsResourceBundle.java rename to test/com/github/tsohr/junit/data/StringsResourceBundle.java index 4479350ec..e04daa766 100644 --- a/src/test/java/org/json/junit/data/StringsResourceBundle.java +++ b/test/com/github/tsohr/junit/data/StringsResourceBundle.java @@ -1,4 +1,4 @@ -package org.json.junit.data; +package com.github.tsohr.junit.data; import java.util.*; diff --git a/src/test/java/org/json/junit/data/WeirdList.java b/test/com/github/tsohr/junit/data/WeirdList.java similarity index 97% rename from src/test/java/org/json/junit/data/WeirdList.java rename to test/com/github/tsohr/junit/data/WeirdList.java index 834b81e86..b6dc21c03 100644 --- a/src/test/java/org/json/junit/data/WeirdList.java +++ b/test/com/github/tsohr/junit/data/WeirdList.java @@ -1,7 +1,7 @@ /** * */ -package org.json.junit.data; +package com.github.tsohr.junit.data; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/test/resources/Issue537.json b/test/resources/Issue537.json similarity index 100% rename from src/test/resources/Issue537.json rename to test/resources/Issue537.json diff --git a/src/test/resources/Issue537.xml b/test/resources/Issue537.xml similarity index 99% rename from src/test/resources/Issue537.xml rename to test/resources/Issue537.xml index bf78f3b39..732683c2a 100644 --- a/src/test/resources/Issue537.xml +++ b/test/resources/Issue537.xml @@ -71,7 +71,7 @@ 2 670 - Neutrophils.Hypersegmented | Bld-Ser-Plas + Neutrophils.Hypersegmented | Bld-Ser-Plas STEMI - ST Elevation Myocardial Infarction Colchicine diff --git a/src/test/resources/jsonpointer-testdoc.json b/test/resources/jsonpointer-testdoc.json similarity index 100% rename from src/test/resources/jsonpointer-testdoc.json rename to test/resources/jsonpointer-testdoc.json