From 5dff8757b744f00d5f14cb3a8e91f4026ac23042 Mon Sep 17 00:00:00 2001 From: "ROMAXTECHNOLOGY\\Younghwan.kim" Date: Wed, 30 Nov 2016 11:22:31 +0000 Subject: [PATCH 01/16] HashMap ==> LinkedHashMap --- .classpath | 20 +++ .gitignore | 2 + .project | 23 +++ .settings/org.eclipse.core.resources.prefs | 3 + .settings/org.eclipse.jdt.core.prefs | 5 + .settings/org.eclipse.m2e.core.prefs | 4 + pom.xml | 151 ++++++++++++++++++ CDL.java => src/com/github/tsohr/CDL.java | 2 +- .../com/github/tsohr/Cookie.java | 2 +- .../com/github/tsohr/CookieList.java | 2 +- HTTP.java => src/com/github/tsohr/HTTP.java | 2 +- .../com/github/tsohr/HTTPTokener.java | 2 +- .../com/github/tsohr/JSONArray.java | 4 +- .../com/github/tsohr/JSONException.java | 2 +- .../com/github/tsohr/JSONML.java | 2 +- .../com/github/tsohr/JSONObject.java | 10 +- .../com/github/tsohr/JSONPointer.java | 2 +- .../github/tsohr/JSONPointerException.java | 2 +- .../com/github/tsohr/JSONString.java | 2 +- .../com/github/tsohr/JSONStringer.java | 2 +- .../com/github/tsohr/JSONTokener.java | 2 +- .../com/github/tsohr/JSONWriter.java | 2 +- .../com/github/tsohr/Property.java | 2 +- XML.java => src/com/github/tsohr/XML.java | 11 +- .../com/github/tsohr/XMLTokener.java | 6 +- 25 files changed, 238 insertions(+), 29 deletions(-) create mode 100644 .classpath create mode 100644 .gitignore create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 pom.xml rename CDL.java => src/com/github/tsohr/CDL.java (99%) rename Cookie.java => src/com/github/tsohr/Cookie.java (99%) rename CookieList.java => src/com/github/tsohr/CookieList.java (99%) rename HTTP.java => src/com/github/tsohr/HTTP.java (96%) rename HTTPTokener.java => src/com/github/tsohr/HTTPTokener.java (98%) rename JSONArray.java => src/com/github/tsohr/JSONArray.java (99%) rename JSONException.java => src/com/github/tsohr/JSONException.java (97%) rename JSONML.java => src/com/github/tsohr/JSONML.java (99%) rename JSONObject.java => src/com/github/tsohr/JSONObject.java (99%) rename JSONPointer.java => src/com/github/tsohr/JSONPointer.java (99%) rename JSONPointerException.java => src/com/github/tsohr/JSONPointerException.java (98%) rename JSONString.java => src/com/github/tsohr/JSONString.java (96%) rename JSONStringer.java => src/com/github/tsohr/JSONStringer.java (96%) rename JSONTokener.java => src/com/github/tsohr/JSONTokener.java (99%) rename JSONWriter.java => src/com/github/tsohr/JSONWriter.java (96%) rename Property.java => src/com/github/tsohr/Property.java (99%) rename XML.java => src/com/github/tsohr/XML.java (99%) rename XMLTokener.java => src/com/github/tsohr/XMLTokener.java (98%) diff --git a/.classpath b/.classpath new file mode 100644 index 000000000..7397c6ef3 --- /dev/null +++ b/.classpath @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..09e3bc9b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/target/ diff --git a/.project b/.project new file mode 100644 index 000000000..f514a79df --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + JSON-java + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..7a5313928 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 +encoding/src=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..abec6ca38 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 000000000..f897a7f1c --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..2f446629a --- /dev/null +++ b/pom.xml @@ -0,0 +1,151 @@ + + 4.0.0 + com.github.tsohr + json + 0.0.1 + jar + + json-ordered + Ordered version of JSONObject + https://github.com/tsohr/JSON-java + + + https://github.com/tsohr/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. + + + + + + UTF-8 + + + + + junit + junit + 4.12 + test + + + com.jayway.jsonpath + json-path + 2.1.0 + test + + + org.mockito + mockito-core + 1.9.5 + test + + + + + src + + + maven-compiler-plugin + 3.3 + + + + + + + org.apache.felix + maven-bundle-plugin + 3.0.1 + true + + + + org.json + + ${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.5 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.3 + true + + ossrh + https://oss.sonatype.org/ + true + + + + + + \ No newline at end of file diff --git a/CDL.java b/src/com/github/tsohr/CDL.java similarity index 99% rename from CDL.java rename to src/com/github/tsohr/CDL.java index 6a82764db..9932b95cb 100644 --- a/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/Cookie.java b/src/com/github/tsohr/Cookie.java similarity index 99% rename from Cookie.java rename to src/com/github/tsohr/Cookie.java index 348dc688d..c18d47bdc 100644 --- a/Cookie.java +++ b/src/com/github/tsohr/Cookie.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org diff --git a/CookieList.java b/src/com/github/tsohr/CookieList.java similarity index 99% rename from CookieList.java rename to src/com/github/tsohr/CookieList.java index 7a5628e91..12109b5ad 100644 --- a/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/HTTP.java b/src/com/github/tsohr/HTTP.java similarity index 96% rename from HTTP.java rename to src/com/github/tsohr/HTTP.java index b14d04ec9..72fefe49a 100644 --- a/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/HTTPTokener.java b/src/com/github/tsohr/HTTPTokener.java similarity index 98% rename from HTTPTokener.java rename to src/com/github/tsohr/HTTPTokener.java index 55f48ffa5..988dbfae3 100644 --- a/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/JSONArray.java b/src/com/github/tsohr/JSONArray.java similarity index 99% rename from JSONArray.java rename to src/com/github/tsohr/JSONArray.java index 2446fd6c4..6b834a34b 100644 --- a/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 @@ -181,7 +181,7 @@ public JSONArray(Object array) throws JSONException { } } - @Override + // from interface public Iterator iterator() { return myArrayList.iterator(); } diff --git a/JSONException.java b/src/com/github/tsohr/JSONException.java similarity index 97% rename from JSONException.java rename to src/com/github/tsohr/JSONException.java index 72542dfb6..0f4939052 100644 --- a/JSONException.java +++ b/src/com/github/tsohr/JSONException.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /** * The JSONException is thrown by the JSON.org classes when things are amiss. diff --git a/JSONML.java b/src/com/github/tsohr/JSONML.java similarity index 99% rename from JSONML.java rename to src/com/github/tsohr/JSONML.java index 82853a944..fa3f85724 100644 --- a/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/JSONObject.java b/src/com/github/tsohr/JSONObject.java similarity index 99% rename from JSONObject.java rename to src/com/github/tsohr/JSONObject.java index 4df256a3b..7a3911b88 100644 --- a/JSONObject.java +++ b/src/com/github/tsohr/JSONObject.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /* Copyright (c) 2002 JSON.org @@ -34,8 +34,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; @@ -155,7 +155,7 @@ public String toString() { * Construct an empty JSONObject. */ public JSONObject() { - this.map = new HashMap(); + this.map = new LinkedHashMap(); } /** @@ -241,7 +241,7 @@ public JSONObject(JSONTokener x) throws JSONException { * the JSONObject. */ public JSONObject(Map map) { - this.map = new HashMap(); + this.map = new LinkedHashMap(); if (map != null) { for (final Entry e : map.entrySet()) { final Object value = e.getValue(); @@ -1919,7 +1919,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.map.entrySet()) { Object value; if (entry.getValue() == null || NULL.equals(entry.getValue())) { diff --git a/JSONPointer.java b/src/com/github/tsohr/JSONPointer.java similarity index 99% rename from JSONPointer.java rename to src/com/github/tsohr/JSONPointer.java index 82de7f933..a4e2a10a6 100644 --- a/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/JSONPointerException.java b/src/com/github/tsohr/JSONPointerException.java similarity index 98% rename from JSONPointerException.java rename to src/com/github/tsohr/JSONPointerException.java index 0ce1aeb29..17155957f 100644 --- a/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/JSONString.java b/src/com/github/tsohr/JSONString.java similarity index 96% rename from JSONString.java rename to src/com/github/tsohr/JSONString.java index 1f2d77dd1..38f665739 100644 --- a/JSONString.java +++ b/src/com/github/tsohr/JSONString.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; /** * The JSONString interface allows a toJSONString() * method so that a class can change the behavior of diff --git a/JSONStringer.java b/src/com/github/tsohr/JSONStringer.java similarity index 96% rename from JSONStringer.java rename to src/com/github/tsohr/JSONStringer.java index 5fbc96a9a..288267c31 100644 --- a/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/JSONTokener.java b/src/com/github/tsohr/JSONTokener.java similarity index 99% rename from JSONTokener.java rename to src/com/github/tsohr/JSONTokener.java index d0b197d73..fe7da49ab 100644 --- a/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/JSONWriter.java b/src/com/github/tsohr/JSONWriter.java similarity index 96% rename from JSONWriter.java rename to src/com/github/tsohr/JSONWriter.java index 696ee2307..a4a2cb35d 100644 --- a/JSONWriter.java +++ b/src/com/github/tsohr/JSONWriter.java @@ -1,4 +1,4 @@ -package org.json; +package com.github.tsohr; import java.io.IOException; diff --git a/Property.java b/src/com/github/tsohr/Property.java similarity index 99% rename from Property.java rename to src/com/github/tsohr/Property.java index 73ddb1287..4b3faf79b 100644 --- a/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/XML.java b/src/com/github/tsohr/XML.java similarity index 99% rename from XML.java rename to src/com/github/tsohr/XML.java index 78dd6a00c..ce44031b9 100644 --- a/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 @@ -75,25 +75,26 @@ public class XML { */ private static Iterable codePointIterator(final String string) { return new Iterable() { - @Override + + // from interface public Iterator iterator() { return new Iterator() { private int nextIndex = 0; private int length = string.length(); - @Override + // from interface public boolean hasNext() { return this.nextIndex < this.length; } - @Override + // from interface public Integer next() { int result = string.codePointAt(this.nextIndex); this.nextIndex += Character.charCount(result); return result; } - @Override + // from interface public void remove() { throw new UnsupportedOperationException(); } diff --git a/XMLTokener.java b/src/com/github/tsohr/XMLTokener.java similarity index 98% rename from XMLTokener.java rename to src/com/github/tsohr/XMLTokener.java index e45e747dc..85822d249 100644 --- a/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 @@ -36,10 +36,10 @@ public class XMLTokener extends JSONTokener { /** The table of entity values. It initially contains Character values for * amp, apos, gt, lt, quot. */ - public static final java.util.HashMap entity; + public static final java.util.LinkedHashMap entity; static { - entity = new java.util.HashMap(8); + entity = new java.util.LinkedHashMap(8); entity.put("amp", XML.AMP); entity.put("apos", XML.APOS); entity.put("gt", XML.GT); From ab2dd684ae0a7ad7635cbfed026d0e64399b6d8e Mon Sep 17 00:00:00 2001 From: "ROMAXTECHNOLOGY\\Younghwan.kim" Date: Wed, 30 Nov 2016 12:13:48 +0000 Subject: [PATCH 02/16] doc fix --- .classpath | 1 + .project | 13 +++++++++++++ .settings/org.eclipse.jdt.core.prefs | 3 +++ .settings/org.eclipse.wst.common.component | 5 +++++ .../org.eclipse.wst.common.project.facet.core.xml | 5 +++++ README | 13 +++++++++++++ pom.xml | 3 +-- src/com/github/tsohr/XML.java | 2 +- 8 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 .settings/org.eclipse.wst.common.component create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/.classpath b/.classpath index 7397c6ef3..612bb5945 100644 --- a/.classpath +++ b/.classpath @@ -14,6 +14,7 @@ + diff --git a/.project b/.project index f514a79df..56069347d 100644 --- a/.project +++ b/.project @@ -5,6 +5,11 @@ + + org.eclipse.wst.common.project.facet.core.builder + + + org.eclipse.jdt.core.javabuilder @@ -15,9 +20,17 @@ + + org.eclipse.wst.validation.validationbuilder + + + + 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/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index abec6ca38..45a6e0e0d 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,8 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.5 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 000000000..0ce243818 --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,5 @@ + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 000000000..f66a2079b --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/README b/README index ce78da41f..78dfa3c6d 100644 --- a/README +++ b/README @@ -1,3 +1,16 @@ + +HashMap ==> LinkedHashMap. + +I know the json spec said it's unordered key-value pairs, but for a human reader +for the output json code, we definitely need ordering. + + + + +======================================================= + + + JSON in Java [package org.json] JSON is a light-weight, language independent, data interchange format. diff --git a/pom.xml b/pom.xml index 2f446629a..5fdd46667 100644 --- a/pom.xml +++ b/pom.xml @@ -4,8 +4,7 @@ com.github.tsohr json 0.0.1 - jar - + json-ordered Ordered version of JSONObject https://github.com/tsohr/JSON-java diff --git a/src/com/github/tsohr/XML.java b/src/com/github/tsohr/XML.java index ce44031b9..2358e7a96 100644 --- a/src/com/github/tsohr/XML.java +++ b/src/com/github/tsohr/XML.java @@ -423,7 +423,7 @@ private static boolean parse(XMLTokener x, JSONObject context, String name, bool } /** - * This method is the same as {@link JSONObject.stringToValue(String)} + * This method is the same as {@link JSONObject#stringToValue(String)} * except that this also tries to unescape String values. * * @param string String to convert From 1790ba0a9fa11dd439c1cad733fd2e40341e9761 Mon Sep 17 00:00:00 2001 From: Younghwan Date: Wed, 30 Nov 2016 13:27:11 +0000 Subject: [PATCH 03/16] pom --- pom.xml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/pom.xml b/pom.xml index 5fdd46667..0c06f4a2f 100644 --- a/pom.xml +++ b/pom.xml @@ -122,7 +122,6 @@ org.apache.maven.plugins maven-gpg-plugin - 1.5 sign-artifacts @@ -133,18 +132,17 @@ - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.3 - true - - ossrh - https://oss.sonatype.org/ - true - - + + org.sonatype.plugins + nexus-staging-maven-plugin + true + + ossrh + https://oss.sonatype.org/ + true + + - \ No newline at end of file + From 5055c909511e62993eed9e21bec79a6eda4b63a9 Mon Sep 17 00:00:00 2001 From: "ROMAXTECHNOLOGY\\Younghwan.kim" Date: Wed, 30 Nov 2016 13:30:38 +0000 Subject: [PATCH 04/16] pom --- pom.xml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 0c06f4a2f..78584df07 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.github.tsohr json 0.0.1 - + json-ordered Ordered version of JSONObject https://github.com/tsohr/JSON-java @@ -132,16 +132,16 @@ - - org.sonatype.plugins - nexus-staging-maven-plugin - true - - ossrh - https://oss.sonatype.org/ - true - - + + org.sonatype.plugins + nexus-staging-maven-plugin + true + + ossrh + https://oss.sonatype.org/ + true + + From 98580eaa829ce1f64405ebfb3b00e72c681273e6 Mon Sep 17 00:00:00 2001 From: "ROMAXTECHNOLOGY\\Younghwan.kim" Date: Wed, 30 Nov 2016 13:34:13 +0000 Subject: [PATCH 05/16] pom developer --- pom.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pom.xml b/pom.xml index 78584df07..6497d5fd6 100644 --- a/pom.xml +++ b/pom.xml @@ -9,6 +9,15 @@ Ordered version of JSONObject https://github.com/tsohr/JSON-java + + + Younghwan Kim + sohrkim@gmail.com + Github + https://github.com/tsohr + + + https://github.com/tsohr/JSON-java.git From a37f62580c164a0df78b5a1f998fb82b8e62f665 Mon Sep 17 00:00:00 2001 From: "ROMAXTECHNOLOGY\\Younghwan.kim" Date: Wed, 30 Nov 2016 13:37:20 +0000 Subject: [PATCH 06/16] pom scm --- pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 6497d5fd6..cc78c1efd 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,9 @@ - https://github.com/tsohr/JSON-java.git + scm:git:https://github.com/tsohr/JSON-java.git + scm:git:https://github.com/tsohr/JSON-java.git + https://github.com/tsohr/JSON-java From 44d909dd5b7e3268fe544b8ec00d37e96d22806d Mon Sep 17 00:00:00 2001 From: Younghwan Date: Wed, 30 Nov 2016 15:33:35 +0000 Subject: [PATCH 07/16] sonatype released 0.0.1 --- README | 10 +- pom.xml | 329 +++++++++++++++++++++++++++++--------------------------- 2 files changed, 179 insertions(+), 160 deletions(-) diff --git a/README b/README index 78dfa3c6d..997598223 100644 --- a/README +++ b/README @@ -4,7 +4,15 @@ HashMap ==> LinkedHashMap. I know the json spec said it's unordered key-value pairs, but for a human reader for the output json code, we definitely need ordering. - + +Maven dependency registered: + +` + com.github.tsohr + json + 0.0.1 + +` ======================================================= diff --git a/pom.xml b/pom.xml index cc78c1efd..f7facb34f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,159 +1,170 @@ - - 4.0.0 - com.github.tsohr - json - 0.0.1 - - json-ordered - Ordered version of JSONObject - https://github.com/tsohr/JSON-java - - - - Younghwan Kim - sohrkim@gmail.com - Github - https://github.com/tsohr - - - - - 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. - - - - - - UTF-8 - - - - - junit - junit - 4.12 - test - - - com.jayway.jsonpath - json-path - 2.1.0 - test - - - org.mockito - mockito-core - 1.9.5 - test - - - - - src - - - maven-compiler-plugin - 3.3 - - - - - - - org.apache.felix - maven-bundle-plugin - 3.0.1 - true - - - - org.json - - ${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 - - - sign-artifacts - verify - - sign - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - true - - ossrh - https://oss.sonatype.org/ - true - - - - - - + + + 4.0.0 + com.github.tsohr + json + 0.0.1 + json-ordered + Ordered version of JSONObject + https://github.com/tsohr/JSON-java + + + Younghwan Kim + sohrkim@gmail.com + Github + https://github.com/tsohr + + + + 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. + + + + + UTF-8 + + + + junit + junit + 4.12 + test + + + com.jayway.jsonpath + json-path + 2.1.0 + test + + + org.mockito + mockito-core + 1.9.5 + test + + + + src + + + maven-compiler-plugin + 3.3 + + + + + + + org.apache.felix + maven-bundle-plugin + 3.0.1 + true + + + + org.json + + ${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 + + + sign-artifacts + verify + + sign + + + + + + org.apache.maven.plugins + maven-release-plugin + + forked-path + false + -Psonatype-oss-release + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 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/ + + + From 3b960d273cf4a7fab3d2ca87d0e3d77e81728a11 Mon Sep 17 00:00:00 2001 From: Younghwan Date: Wed, 30 Nov 2016 15:36:01 +0000 Subject: [PATCH 08/16] README --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 997598223..6d0de6df9 100644 --- a/README +++ b/README @@ -7,12 +7,12 @@ for the output json code, we definitely need ordering. Maven dependency registered: -` +``` com.github.tsohr json 0.0.1 -` +``` ======================================================= From e974f54433ea2202a8b705103247542f6fb617fd Mon Sep 17 00:00:00 2001 From: Younghwan Date: Wed, 30 Nov 2016 15:36:28 +0000 Subject: [PATCH 09/16] README --- README | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README b/README index 6d0de6df9..6d4212dc2 100644 --- a/README +++ b/README @@ -7,7 +7,8 @@ for the output json code, we definitely need ordering. Maven dependency registered: -``` +``` + com.github.tsohr json 0.0.1 From df884fcb62e16e8962e845d04938b1107f96e6fd Mon Sep 17 00:00:00 2001 From: Younghwan Kim Date: Mon, 8 Mar 2021 10:26:27 +0900 Subject: [PATCH 10/16] package renamed, receive update from stleary/JSON-java --- .classpath | 10 ++-- pom.xml | 7 +-- .../github/tsohr}/junit/CDLTest.java | 8 +-- .../github/tsohr}/junit/CookieListTest.java | 2 +- .../github/tsohr}/junit/CookieTest.java | 2 +- .../github/tsohr}/junit/EnumTest.java | 12 ++--- .../github/tsohr}/junit/HTTPTest.java | 2 +- .../github/tsohr}/junit/JSONArrayTest.java | 10 ++-- .../github/tsohr}/junit/JSONMLTest.java | 4 +- .../tsohr}/junit/JSONObjectLocaleTest.java | 4 +- .../github/tsohr}/junit/JSONObjectTest.java | 54 +++++++++---------- .../github/tsohr}/junit/JSONPointerTest.java | 10 ++-- .../github/tsohr}/junit/JSONStringTest.java | 2 +- .../github/tsohr}/junit/JSONStringerTest.java | 2 +- .../github/tsohr}/junit/JSONTokenerTest.java | 10 ++-- .../github/tsohr}/junit/PropertyTest.java | 2 +- .../json => com/github/tsohr}/junit/Util.java | 2 +- .../tsohr}/junit/XMLConfigurationTest.java | 10 ++-- .../github/tsohr}/junit/XMLTest.java | 14 ++--- .../tsohr}/junit/data/BrokenToString.java | 0 .../tsohr}/junit/data/ExceptionalBean.java | 0 .../github/tsohr}/junit/data/Fraction.java | 0 .../github/tsohr}/junit/data/GenericBean.java | 0 .../tsohr}/junit/data/GenericBeanInt.java | 0 .../github/tsohr}/junit/data/MyBean.java | 0 .../tsohr}/junit/data/MyBeanCustomName.java | 2 +- .../junit/data/MyBeanCustomNameInterface.java | 4 +- .../junit/data/MyBeanCustomNameSubClass.java | 6 +-- .../tsohr}/junit/data/MyBigNumberBean.java | 0 .../github/tsohr}/junit/data/MyEnum.java | 0 .../github/tsohr}/junit/data/MyEnumClass.java | 0 .../github/tsohr}/junit/data/MyEnumField.java | 0 .../tsohr}/junit/data/MyJsonString.java | 2 +- .../tsohr}/junit/data/MyLocaleBean.java | 0 .../github/tsohr}/junit/data/MyNumber.java | 0 .../tsohr}/junit/data/MyNumberContainer.java | 0 .../tsohr}/junit/data/MyPublicClass.java | 0 .../github/tsohr}/junit/data/Singleton.java | 0 .../tsohr}/junit/data/SingletonEnum.java | 0 .../junit/data/StringsResourceBundle.java | 0 .../github/tsohr}/junit/data/WeirdList.java | 0 test/resources/Issue537.xml | 2 +- 42 files changed, 92 insertions(+), 91 deletions(-) rename test/{java/org/json => com/github/tsohr}/junit/CDLTest.java (98%) rename test/{java/org/json => com/github/tsohr}/junit/CookieListTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/CookieTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/EnumTest.java (98%) rename test/{java/org/json => com/github/tsohr}/junit/HTTPTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/JSONArrayTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/JSONMLTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/JSONObjectLocaleTest.java (97%) rename test/{java/org/json => com/github/tsohr}/junit/JSONObjectTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/JSONPointerTest.java (98%) rename test/{java/org/json => com/github/tsohr}/junit/JSONStringTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/JSONStringerTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/JSONTokenerTest.java (98%) rename test/{java/org/json => com/github/tsohr}/junit/PropertyTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/Util.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/XMLConfigurationTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/XMLTest.java (99%) rename test/{java/org/json => com/github/tsohr}/junit/data/BrokenToString.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/ExceptionalBean.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/Fraction.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/GenericBean.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/GenericBeanInt.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyBean.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyBeanCustomName.java (93%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyBeanCustomNameInterface.java (69%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyBeanCustomNameSubClass.java (82%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyBigNumberBean.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyEnum.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyEnumClass.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyEnumField.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyJsonString.java (89%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyLocaleBean.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyNumber.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyNumberContainer.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/MyPublicClass.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/Singleton.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/SingletonEnum.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/StringsResourceBundle.java (100%) rename test/{java/org/json => com/github/tsohr}/junit/data/WeirdList.java (100%) diff --git a/.classpath b/.classpath index 5fd56a9b6..17248354e 100644 --- a/.classpath +++ b/.classpath @@ -1,10 +1,5 @@ - - - - - @@ -24,5 +19,10 @@ + + + + + diff --git a/pom.xml b/pom.xml index 266f9a04a..a67d88e9e 100644 --- a/pom.xml +++ b/pom.xml @@ -81,10 +81,11 @@ maven-compiler-plugin - 3.3 + 3.6.1 - - + 1.8 + 1.8 + UTF-8 diff --git a/test/java/org/json/junit/CDLTest.java b/test/com/github/tsohr/junit/CDLTest.java similarity index 98% rename from test/java/org/json/junit/CDLTest.java rename to test/com/github/tsohr/junit/CDLTest.java index d5bd48c85..b82c4e226 100644 --- a/test/java/org/json/junit/CDLTest.java +++ b/test/com/github/tsohr/junit/CDLTest.java @@ -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/test/java/org/json/junit/CookieListTest.java b/test/com/github/tsohr/junit/CookieListTest.java similarity index 99% rename from test/java/org/json/junit/CookieListTest.java rename to test/com/github/tsohr/junit/CookieListTest.java index 743973fa5..c61bf8525 100644 --- a/test/java/org/json/junit/CookieListTest.java +++ b/test/com/github/tsohr/junit/CookieListTest.java @@ -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/test/java/org/json/junit/CookieTest.java b/test/com/github/tsohr/junit/CookieTest.java similarity index 99% rename from test/java/org/json/junit/CookieTest.java rename to test/com/github/tsohr/junit/CookieTest.java index ab9fac98a..7ec9966ef 100644 --- a/test/java/org/json/junit/CookieTest.java +++ b/test/com/github/tsohr/junit/CookieTest.java @@ -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/test/java/org/json/junit/EnumTest.java b/test/com/github/tsohr/junit/EnumTest.java similarity index 98% rename from test/java/org/json/junit/EnumTest.java rename to test/com/github/tsohr/junit/EnumTest.java index 50e43cf5c..843c0461b 100644 --- a/test/java/org/json/junit/EnumTest.java +++ b/test/com/github/tsohr/junit/EnumTest.java @@ -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/test/java/org/json/junit/HTTPTest.java b/test/com/github/tsohr/junit/HTTPTest.java similarity index 99% rename from test/java/org/json/junit/HTTPTest.java rename to test/com/github/tsohr/junit/HTTPTest.java index ee39e3552..e0d6e5c35 100644 --- a/test/java/org/json/junit/HTTPTest.java +++ b/test/com/github/tsohr/junit/HTTPTest.java @@ -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/test/java/org/json/junit/JSONArrayTest.java b/test/com/github/tsohr/junit/JSONArrayTest.java similarity index 99% rename from test/java/org/json/junit/JSONArrayTest.java rename to test/com/github/tsohr/junit/JSONArrayTest.java index 67a1a41d0..7547973f4 100644 --- a/test/java/org/json/junit/JSONArrayTest.java +++ b/test/com/github/tsohr/junit/JSONArrayTest.java @@ -43,10 +43,10 @@ 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.JSONException; -import org.json.JSONObject; -import org.json.JSONPointerException; +import com.github.tsohr.JSONArray; +import com.github.tsohr.JSONException; +import com.github.tsohr.JSONObject; +import com.github.tsohr.JSONPointerException; import org.junit.Test; import com.jayway.jsonpath.Configuration; @@ -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/test/java/org/json/junit/JSONMLTest.java b/test/com/github/tsohr/junit/JSONMLTest.java similarity index 99% rename from test/java/org/json/junit/JSONMLTest.java rename to test/com/github/tsohr/junit/JSONMLTest.java index f0295a6d0..787a9e867 100644 --- a/test/java/org/json/junit/JSONMLTest.java +++ b/test/com/github/tsohr/junit/JSONMLTest.java @@ -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/test/java/org/json/junit/JSONObjectLocaleTest.java b/test/com/github/tsohr/junit/JSONObjectLocaleTest.java similarity index 97% rename from test/java/org/json/junit/JSONObjectLocaleTest.java rename to test/com/github/tsohr/junit/JSONObjectLocaleTest.java index 4855c2911..3c7bd0b6f 100644 --- a/test/java/org/json/junit/JSONObjectLocaleTest.java +++ b/test/com/github/tsohr/junit/JSONObjectLocaleTest.java @@ -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/test/java/org/json/junit/JSONObjectTest.java b/test/com/github/tsohr/junit/JSONObjectTest.java similarity index 99% rename from test/java/org/json/junit/JSONObjectTest.java rename to test/com/github/tsohr/junit/JSONObjectTest.java index b8ceb756e..54d9d7921 100644 --- a/test/java/org/json/junit/JSONObjectTest.java +++ b/test/com/github/tsohr/junit/JSONObjectTest.java @@ -51,31 +51,31 @@ of this software and associated documentation files (the "Software"), to deal 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 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 org.junit.Test; import com.jayway.jsonpath.Configuration; @@ -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 @@ -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/test/java/org/json/junit/JSONPointerTest.java b/test/com/github/tsohr/junit/JSONPointerTest.java similarity index 98% rename from test/java/org/json/junit/JSONPointerTest.java rename to test/com/github/tsohr/junit/JSONPointerTest.java index aa9ee2160..b838805de 100644 --- a/test/java/org/json/junit/JSONPointerTest.java +++ b/test/com/github/tsohr/junit/JSONPointerTest.java @@ -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/test/java/org/json/junit/JSONStringTest.java b/test/com/github/tsohr/junit/JSONStringTest.java similarity index 99% rename from test/java/org/json/junit/JSONStringTest.java rename to test/com/github/tsohr/junit/JSONStringTest.java index 391e6f557..6b0c4fed7 100644 --- a/test/java/org/json/junit/JSONStringTest.java +++ b/test/com/github/tsohr/junit/JSONStringTest.java @@ -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/test/java/org/json/junit/JSONStringerTest.java b/test/com/github/tsohr/junit/JSONStringerTest.java similarity index 99% rename from test/java/org/json/junit/JSONStringerTest.java rename to test/com/github/tsohr/junit/JSONStringerTest.java index 630e5553d..ba0a40566 100644 --- a/test/java/org/json/junit/JSONStringerTest.java +++ b/test/com/github/tsohr/junit/JSONStringerTest.java @@ -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/test/java/org/json/junit/JSONTokenerTest.java b/test/com/github/tsohr/junit/JSONTokenerTest.java similarity index 98% rename from test/java/org/json/junit/JSONTokenerTest.java rename to test/com/github/tsohr/junit/JSONTokenerTest.java index d1f34df0e..7dd1c14e0 100644 --- a/test/java/org/json/junit/JSONTokenerTest.java +++ b/test/com/github/tsohr/junit/JSONTokenerTest.java @@ -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/test/java/org/json/junit/PropertyTest.java b/test/com/github/tsohr/junit/PropertyTest.java similarity index 99% rename from test/java/org/json/junit/PropertyTest.java rename to test/com/github/tsohr/junit/PropertyTest.java index fa57c9d81..60390a21d 100644 --- a/test/java/org/json/junit/PropertyTest.java +++ b/test/com/github/tsohr/junit/PropertyTest.java @@ -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/test/java/org/json/junit/Util.java b/test/com/github/tsohr/junit/Util.java similarity index 99% rename from test/java/org/json/junit/Util.java rename to test/com/github/tsohr/junit/Util.java index 2c029fdf2..a8784d4b6 100644 --- a/test/java/org/json/junit/Util.java +++ b/test/com/github/tsohr/junit/Util.java @@ -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/test/java/org/json/junit/XMLConfigurationTest.java b/test/com/github/tsohr/junit/XMLConfigurationTest.java similarity index 99% rename from test/java/org/json/junit/XMLConfigurationTest.java rename to test/com/github/tsohr/junit/XMLConfigurationTest.java index 6885b4cae..2317e563a 100644 --- a/test/java/org/json/junit/XMLConfigurationTest.java +++ b/test/com/github/tsohr/junit/XMLConfigurationTest.java @@ -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/test/java/org/json/junit/XMLTest.java b/test/com/github/tsohr/junit/XMLTest.java similarity index 99% rename from test/java/org/json/junit/XMLTest.java rename to test/com/github/tsohr/junit/XMLTest.java index 4caeb2276..dfed611c6 100644 --- a/test/java/org/json/junit/XMLTest.java +++ b/test/com/github/tsohr/junit/XMLTest.java @@ -41,13 +41,13 @@ of this software and associated documentation files (the "Software"), to deal import java.util.HashMap; 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 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; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; diff --git a/test/java/org/json/junit/data/BrokenToString.java b/test/com/github/tsohr/junit/data/BrokenToString.java similarity index 100% rename from test/java/org/json/junit/data/BrokenToString.java rename to test/com/github/tsohr/junit/data/BrokenToString.java diff --git a/test/java/org/json/junit/data/ExceptionalBean.java b/test/com/github/tsohr/junit/data/ExceptionalBean.java similarity index 100% rename from test/java/org/json/junit/data/ExceptionalBean.java rename to test/com/github/tsohr/junit/data/ExceptionalBean.java diff --git a/test/java/org/json/junit/data/Fraction.java b/test/com/github/tsohr/junit/data/Fraction.java similarity index 100% rename from test/java/org/json/junit/data/Fraction.java rename to test/com/github/tsohr/junit/data/Fraction.java diff --git a/test/java/org/json/junit/data/GenericBean.java b/test/com/github/tsohr/junit/data/GenericBean.java similarity index 100% rename from test/java/org/json/junit/data/GenericBean.java rename to test/com/github/tsohr/junit/data/GenericBean.java diff --git a/test/java/org/json/junit/data/GenericBeanInt.java b/test/com/github/tsohr/junit/data/GenericBeanInt.java similarity index 100% rename from test/java/org/json/junit/data/GenericBeanInt.java rename to test/com/github/tsohr/junit/data/GenericBeanInt.java diff --git a/test/java/org/json/junit/data/MyBean.java b/test/com/github/tsohr/junit/data/MyBean.java similarity index 100% rename from test/java/org/json/junit/data/MyBean.java rename to test/com/github/tsohr/junit/data/MyBean.java diff --git a/test/java/org/json/junit/data/MyBeanCustomName.java b/test/com/github/tsohr/junit/data/MyBeanCustomName.java similarity index 93% rename from test/java/org/json/junit/data/MyBeanCustomName.java rename to test/com/github/tsohr/junit/data/MyBeanCustomName.java index c1297c1c2..217753549 100644 --- a/test/java/org/json/junit/data/MyBeanCustomName.java +++ b/test/com/github/tsohr/junit/data/MyBeanCustomName.java @@ -1,6 +1,6 @@ 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/test/java/org/json/junit/data/MyBeanCustomNameInterface.java b/test/com/github/tsohr/junit/data/MyBeanCustomNameInterface.java similarity index 69% rename from test/java/org/json/junit/data/MyBeanCustomNameInterface.java rename to test/com/github/tsohr/junit/data/MyBeanCustomNameInterface.java index 58f8cfab7..5ebfce806 100644 --- a/test/java/org/json/junit/data/MyBeanCustomNameInterface.java +++ b/test/com/github/tsohr/junit/data/MyBeanCustomNameInterface.java @@ -1,7 +1,7 @@ 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/test/java/org/json/junit/data/MyBeanCustomNameSubClass.java b/test/com/github/tsohr/junit/data/MyBeanCustomNameSubClass.java similarity index 82% rename from test/java/org/json/junit/data/MyBeanCustomNameSubClass.java rename to test/com/github/tsohr/junit/data/MyBeanCustomNameSubClass.java index 676164d7b..d4740e638 100644 --- a/test/java/org/json/junit/data/MyBeanCustomNameSubClass.java +++ b/test/com/github/tsohr/junit/data/MyBeanCustomNameSubClass.java @@ -3,11 +3,11 @@ */ 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/test/java/org/json/junit/data/MyBigNumberBean.java b/test/com/github/tsohr/junit/data/MyBigNumberBean.java similarity index 100% rename from test/java/org/json/junit/data/MyBigNumberBean.java rename to test/com/github/tsohr/junit/data/MyBigNumberBean.java diff --git a/test/java/org/json/junit/data/MyEnum.java b/test/com/github/tsohr/junit/data/MyEnum.java similarity index 100% rename from test/java/org/json/junit/data/MyEnum.java rename to test/com/github/tsohr/junit/data/MyEnum.java diff --git a/test/java/org/json/junit/data/MyEnumClass.java b/test/com/github/tsohr/junit/data/MyEnumClass.java similarity index 100% rename from test/java/org/json/junit/data/MyEnumClass.java rename to test/com/github/tsohr/junit/data/MyEnumClass.java diff --git a/test/java/org/json/junit/data/MyEnumField.java b/test/com/github/tsohr/junit/data/MyEnumField.java similarity index 100% rename from test/java/org/json/junit/data/MyEnumField.java rename to test/com/github/tsohr/junit/data/MyEnumField.java diff --git a/test/java/org/json/junit/data/MyJsonString.java b/test/com/github/tsohr/junit/data/MyJsonString.java similarity index 89% rename from test/java/org/json/junit/data/MyJsonString.java rename to test/com/github/tsohr/junit/data/MyJsonString.java index 9530985cd..e067bdde6 100644 --- a/test/java/org/json/junit/data/MyJsonString.java +++ b/test/com/github/tsohr/junit/data/MyJsonString.java @@ -1,6 +1,6 @@ package com.github.tsohr.junit.data; -import org.json.*; +import com.github.tsohr.*; /** * Used in testing when a JSONString is needed diff --git a/test/java/org/json/junit/data/MyLocaleBean.java b/test/com/github/tsohr/junit/data/MyLocaleBean.java similarity index 100% rename from test/java/org/json/junit/data/MyLocaleBean.java rename to test/com/github/tsohr/junit/data/MyLocaleBean.java diff --git a/test/java/org/json/junit/data/MyNumber.java b/test/com/github/tsohr/junit/data/MyNumber.java similarity index 100% rename from test/java/org/json/junit/data/MyNumber.java rename to test/com/github/tsohr/junit/data/MyNumber.java diff --git a/test/java/org/json/junit/data/MyNumberContainer.java b/test/com/github/tsohr/junit/data/MyNumberContainer.java similarity index 100% rename from test/java/org/json/junit/data/MyNumberContainer.java rename to test/com/github/tsohr/junit/data/MyNumberContainer.java diff --git a/test/java/org/json/junit/data/MyPublicClass.java b/test/com/github/tsohr/junit/data/MyPublicClass.java similarity index 100% rename from test/java/org/json/junit/data/MyPublicClass.java rename to test/com/github/tsohr/junit/data/MyPublicClass.java diff --git a/test/java/org/json/junit/data/Singleton.java b/test/com/github/tsohr/junit/data/Singleton.java similarity index 100% rename from test/java/org/json/junit/data/Singleton.java rename to test/com/github/tsohr/junit/data/Singleton.java diff --git a/test/java/org/json/junit/data/SingletonEnum.java b/test/com/github/tsohr/junit/data/SingletonEnum.java similarity index 100% rename from test/java/org/json/junit/data/SingletonEnum.java rename to test/com/github/tsohr/junit/data/SingletonEnum.java diff --git a/test/java/org/json/junit/data/StringsResourceBundle.java b/test/com/github/tsohr/junit/data/StringsResourceBundle.java similarity index 100% rename from test/java/org/json/junit/data/StringsResourceBundle.java rename to test/com/github/tsohr/junit/data/StringsResourceBundle.java diff --git a/test/java/org/json/junit/data/WeirdList.java b/test/com/github/tsohr/junit/data/WeirdList.java similarity index 100% rename from test/java/org/json/junit/data/WeirdList.java rename to test/com/github/tsohr/junit/data/WeirdList.java diff --git a/test/resources/Issue537.xml b/test/resources/Issue537.xml index bf78f3b39..732683c2a 100644 --- a/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 From 35474068317774bdd3cb6885fb427934bb469def Mon Sep 17 00:00:00 2001 From: Younghwan Kim Date: Mon, 8 Mar 2021 10:29:14 +0900 Subject: [PATCH 11/16] new HashMap() => new LinkedHashMap() --- src/com/github/tsohr/JSONObject.java | 12 ++++----- .../github/tsohr/XMLParserConfiguration.java | 8 +++--- src/com/github/tsohr/XMLXsiTypeConverter.java | 2 +- .../com/github/tsohr/junit/JSONArrayTest.java | 10 +++---- .../github/tsohr/junit/JSONObjectTest.java | 26 +++++++++---------- test/com/github/tsohr/junit/XMLTest.java | 17 ++++++------ 6 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/com/github/tsohr/JSONObject.java b/src/com/github/tsohr/JSONObject.java index 932c9a1f1..9afa5d895 100644 --- a/src/com/github/tsohr/JSONObject.java +++ b/src/com/github/tsohr/JSONObject.java @@ -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); } /** @@ -2596,7 +2596,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/com/github/tsohr/XMLParserConfiguration.java b/src/com/github/tsohr/XMLParserConfiguration.java index 41269554d..e41e39115 100644 --- a/src/com/github/tsohr/XMLParserConfiguration.java +++ b/src/com/github/tsohr/XMLParserConfiguration.java @@ -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/com/github/tsohr/XMLXsiTypeConverter.java b/src/com/github/tsohr/XMLXsiTypeConverter.java index b5dce8cab..fab57de57 100644 --- a/src/com/github/tsohr/XMLXsiTypeConverter.java +++ b/src/com/github/tsohr/XMLXsiTypeConverter.java @@ -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/test/com/github/tsohr/junit/JSONArrayTest.java b/test/com/github/tsohr/junit/JSONArrayTest.java index 7547973f4..890e20905 100644 --- a/test/com/github/tsohr/junit/JSONArrayTest.java +++ b/test/com/github/tsohr/junit/JSONArrayTest.java @@ -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.junit.Test; + import com.github.tsohr.JSONArray; import com.github.tsohr.JSONException; import com.github.tsohr.JSONObject; import com.github.tsohr.JSONPointerException; -import org.junit.Test; - 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 { diff --git a/test/com/github/tsohr/junit/JSONObjectTest.java b/test/com/github/tsohr/junit/JSONObjectTest.java index 54d9d7921..65a9ea34e 100644 --- a/test/com/github/tsohr/junit/JSONObjectTest.java +++ b/test/com/github/tsohr/junit/JSONObjectTest.java @@ -44,13 +44,15 @@ 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.junit.Test; + import com.github.tsohr.CDL; import com.github.tsohr.JSONArray; import com.github.tsohr.JSONException; @@ -76,8 +78,6 @@ of this software and associated documentation files (the "Software"), to deal import com.github.tsohr.junit.data.Singleton; import com.github.tsohr.junit.data.SingletonEnum; import com.github.tsohr.junit.data.WeirdList; -import org.junit.Test; - 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!"); @@ -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"); diff --git a/test/com/github/tsohr/junit/XMLTest.java b/test/com/github/tsohr/junit/XMLTest.java index dfed611c6..33167b123 100644 --- a/test/com/github/tsohr/junit/XMLTest.java +++ b/test/com/github/tsohr/junit/XMLTest.java @@ -38,9 +38,13 @@ 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.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; @@ -48,9 +52,6 @@ of this software and associated documentation files (the "Software"), to deal import com.github.tsohr.XML; import com.github.tsohr.XMLParserConfiguration; import com.github.tsohr.XMLXsiTypeConverter; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; /** @@ -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) { From 612e860890e78d7f9e9251aa2e44437e9b96bd5b Mon Sep 17 00:00:00 2001 From: Younghwan Kim Date: Mon, 8 Mar 2021 10:34:33 +0900 Subject: [PATCH 12/16] fix test resource path --- .classpath | 4 ++-- pom.xml | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.classpath b/.classpath index 17248354e..89242250d 100644 --- a/.classpath +++ b/.classpath @@ -12,7 +12,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/pom.xml b/pom.xml index a67d88e9e..13b6b5c93 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,16 @@ src/ test/ + + + test/resources/ + + **/*.java + + false + + + maven-compiler-plugin From 5129bca5945ba33e39e884439701d680b189b6f7 Mon Sep 17 00:00:00 2001 From: Younghwan Kim Date: Mon, 8 Mar 2021 11:18:55 +0900 Subject: [PATCH 13/16] Adding nullable functions --- src/com/github/tsohr/JSONObject.java | 112 +++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/src/com/github/tsohr/JSONObject.java b/src/com/github/tsohr/JSONObject.java index 9afa5d895..01bee8222 100644 --- a/src/com/github/tsohr/JSONObject.java +++ b/src/com/github/tsohr/JSONObject.java @@ -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 From 5d0dd060b3b36d78804861ddfa4bf5a209ecf8f9 Mon Sep 17 00:00:00 2001 From: Younghwan Kim Date: Mon, 8 Mar 2021 13:16:00 +0900 Subject: [PATCH 14/16] Minimum java version set to 1.8 --- README.md | 3 ++- pom.xml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 41a288cf5..8d44854eb 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ Maven dependency registered: ``` - + * Minimum Java version set to 1.8 + JSON in Java [package org.json] diff --git a/pom.xml b/pom.xml index 13b6b5c93..ed5f27864 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.github.tsohr json - 0.0.1 + 0.0.2 json-ordered Ordered version of JSONObject https://github.com/tsohr/JSON-java @@ -144,6 +144,7 @@ org.apache.maven.plugins maven-gpg-plugin + 1.6 sign-artifacts From eb5dc80a336e6fae196936509f31dcd8121ccd26 Mon Sep 17 00:00:00 2001 From: Younghwan Kim Date: Mon, 8 Mar 2021 13:31:56 +0900 Subject: [PATCH 15/16] Update pipeline.yml Dropping 1.6 and 1.7 compatibility --- .github/workflows/pipeline.yml | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) 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/ From 5f3447f8e802c2ef15bd26a7d75c357cb29e60e9 Mon Sep 17 00:00:00 2001 From: Younghwan Kim Date: Mon, 8 Mar 2021 14:17:46 +0900 Subject: [PATCH 16/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8d44854eb..13c9c677c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Maven dependency registered: com.github.tsohr json - 0.0.1 + 0.0.2 ```