You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@velocity.apache.org by mi...@apache.org on 2018/09/30 19:48:35 UTC

svn commit: r1842407 - in /velocity/tools/branches/VELTOOLS-179/velocity-tools-generic: pom.xml src/main/java/org/apache/velocity/tools/generic/JsonContent.java src/main/java/org/apache/velocity/tools/generic/JsonTool.java

Author: michaelo
Date: Sun Sep 30 19:48:34 2018
New Revision: 1842407

URL: http://svn.apache.org/viewvc?rev=1842407&view=rev
Log:
[VELTOOLS-179] Move JSON Simple to new fork on GH and don't shade it

Modified:
    velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/pom.xml
    velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonContent.java
    velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonTool.java

Modified: velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/pom.xml
URL: http://svn.apache.org/viewvc/velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/pom.xml?rev=1842407&r1=1842406&r2=1842407&view=diff
==============================================================================
--- velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/pom.xml (original)
+++ velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/pom.xml Sun Sep 30 19:48:34 2018
@@ -57,9 +57,9 @@
       <artifactId>slf4j-api</artifactId>
     </dependency>
     <dependency>
-      <groupId>com.googlecode.json-simple</groupId>
+      <groupId>com.github.cliftonlabs</groupId>
       <artifactId>json-simple</artifactId>
-      <version>1.1.1</version>
+      <version>3.0.2</version>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
@@ -72,40 +72,4 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-shade-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>shade</id>
-            <phase>package</phase>
-            <goals>
-              <goal>shade</goal>
-            </goals>
-            <configuration>
-              <artifactSet>
-                <includes>
-                  <include>com.googlecode.json-simple:json-simple</include>
-                </includes>
-              </artifactSet>
-              <relocations>
-                <relocation>
-                  <pattern>org.json.simple</pattern>
-                  <shadedPattern>org.apache.velocity.tools.shaded.org.json.simple</shadedPattern>
-                </relocation>
-                <relocation>
-                  <pattern>org.json.simple.parser</pattern>
-                  <shadedPattern>org.apache.velocity.tools.shaded.org.json.simple.parser</shadedPattern>
-                </relocation>
-              </relocations>
-              <minimizeJar>true</minimizeJar>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
 </project>

Modified: velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonContent.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonContent.java?rev=1842407&r1=1842406&r2=1842407&view=diff
==============================================================================
--- velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonContent.java (original)
+++ velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonContent.java Sun Sep 30 19:48:34 2018
@@ -22,8 +22,8 @@ package org.apache.velocity.tools.generi
 import java.util.Iterator;
 import java.util.Set;
 
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
+import com.github.cliftonlabs.json_simple.JsonArray;
+import com.github.cliftonlabs.json_simple.JsonObject;
 
 /**
  * Container for *either* an array *or* an object
@@ -34,12 +34,12 @@ public class JsonContent
     /**
      * JSONObject content
      */
-    private JSONObject jsonObject = null;
-        
+    private JsonObject jsonObject = null;
+
     /**
      * JSONArray content
      */
-    private JSONArray jsonArray = null;
+    private JsonArray jsonArray = null;
 
     /**
      * wraps the object into an hybrid JSON container if necessary
@@ -50,24 +50,24 @@ public class JsonContent
         {
             return obj;
         }
-        else if (obj instanceof JSONArray)
+        else if (obj instanceof JsonArray)
         {
-            return new JsonContent((JSONArray)obj);
+            return new JsonContent((JsonArray)obj);
         }
-        else if (obj instanceof JSONObject)
+        else if (obj instanceof JsonObject)
         {
-            return new JsonContent((JSONObject)obj);
+            return new JsonContent((JsonObject)obj);
         }
         else
         {
             return obj;
         }
     }
-        
+
     /**
      * wraps an object
      */
-    public JsonContent(JSONObject object)
+    public JsonContent(JsonObject object)
     {
         jsonObject = object;
     }
@@ -75,7 +75,7 @@ public class JsonContent
     /**
      * wraps an array
      */
-    public JsonContent(JSONArray array)
+    public JsonContent(JsonArray array)
     {
         jsonArray = array;
     }
@@ -98,7 +98,7 @@ public class JsonContent
         }
         return ret;
     }
-        
+
     /**
      * Get a property from root object
      * @param key
@@ -121,7 +121,7 @@ public class JsonContent
         }
         return ret;
     }
-        
+
     /**
      * Iterate keys of root object.
      * @return iterator
@@ -174,7 +174,7 @@ public class JsonContent
     public String toString()
     {
         return jsonObject == null ? jsonArray == null ? "null" : jsonArray.toString() : jsonObject.toString();
-    }        
+    }
 
     /**
      * Check if wrapped object is null
@@ -184,16 +184,16 @@ public class JsonContent
     {
         return jsonArray == null && jsonObject == null;
     }
-        
+
     /**
      * Check if wrapped object is a JSONObject
-     * @return true if wrapped object is a JSONObject         
+     * @return true if wrapped object is a JSONObject
      */
     public boolean isObject()
     {
         return jsonObject != null;
     }
-        
+
     /**
      * Check if wrapped object is a JSONArray
      * @return true if wrapped object is a JSONArray

Modified: velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonTool.java?rev=1842407&r1=1842406&r2=1842407&view=diff
==============================================================================
--- velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonTool.java (original)
+++ velocity/tools/branches/VELTOOLS-179/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/JsonTool.java Sun Sep 30 19:48:34 2018
@@ -26,16 +26,16 @@ import java.io.StringReader;
 import java.util.Iterator;
 import java.util.Set;
 
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
-import org.json.simple.parser.JSONParser;
-
 import org.apache.velocity.tools.Scope;
 import org.apache.velocity.tools.config.DefaultKey;
 import org.apache.velocity.tools.config.InvalidScope;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
+import com.github.cliftonlabs.json_simple.JsonArray;
+import com.github.cliftonlabs.json_simple.JsonObject;
+import com.github.cliftonlabs.json_simple.Jsoner;
+
 /**
  * <p>Tool which can parse a JSON file.</p>
  * <p>Usage:</p>
@@ -138,14 +138,14 @@ public class JsonTool extends ImportSupp
     {
         try
         {
-            Object result = new JSONParser().parse(reader);
-            if (result instanceof JSONObject)
+            Object result = Jsoner.deserialize(reader);
+            if (result instanceof JsonObject)
             {
-                root = new JsonContent((JSONObject)result);
+                root = new JsonContent((JsonObject)result);
             }
-            else if (result instanceof JSONArray)
+            else if (result instanceof JsonArray)
             {
-                root = new JsonContent((JSONArray)result);
+                root = new JsonContent((JsonArray)result);
             }
             else throw new Exception("Expecting JSON array or object");
         }