felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlean...@apache.org
Subject svn commit: r1784722 - in /felix/trunk: converter/schematizer/ converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/ converter/serializer/ converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/ converter/serializ...
Date Tue, 28 Feb 2017 11:03:27 GMT
Author: dleangen
Date: Tue Feb 28 11:03:27 2017
New Revision: 1784722

URL: http://svn.apache.org/viewvc?rev=1784722&view=rev
Log:
FELIX-5571: Replace JSONParser in Serializer with the new one from utils

Removed:
    felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java
    felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonParser.java
Modified:
    felix/trunk/converter/schematizer/pom.xml
    felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
    felix/trunk/converter/serializer/pom.xml
    felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
    felix/trunk/converter/serializer/src/test/java/org/apache/felix/serializer/impl/json/JsonParserTest.java
    felix/trunk/utils/src/main/java/org/apache/felix/utils/json/JSONParser.java

Modified: felix/trunk/converter/schematizer/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/pom.xml?rev=1784722&r1=1784721&r2=1784722&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/pom.xml (original)
+++ felix/trunk/converter/schematizer/pom.xml Tue Feb 28 11:03:27 2017
@@ -122,7 +122,14 @@
             <version>6.0.0</version>
             <scope>provided</scope>
         </dependency>
-        
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.utils</artifactId>
+            <version>1.9.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>

Modified: felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java?rev=1784722&r1=1784721&r2=1784722&view=diff
==============================================================================
--- felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
(original)
+++ felix/trunk/converter/schematizer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
Tue Feb 28 11:03:27 2017
@@ -33,6 +33,7 @@ import org.apache.felix.schematizer.Node
 import org.apache.felix.schematizer.Schema;
 import org.apache.felix.schematizer.Schematizing;
 import org.apache.felix.schematizer.impl.Util;
+import org.apache.felix.utils.json.JSONParser;
 import org.osgi.dto.DTO;
 import org.osgi.service.serializer.Deserializing;
 import org.osgi.util.converter.ConversionException;
@@ -65,7 +66,7 @@ public class JsonDeserializingImpl<T> im
     @Override
     @SuppressWarnings("unchecked")
     public T from(CharSequence in) {
-        JsonParser jp = new JsonParser(in);
+        JSONParser jp = new JSONParser(in);
         Map<?,?> m = jp.getParsed();
         Class<T> clazz = (Class<T>)Util.rawClassOf(target);
         if (m.getClass().isAssignableFrom(clazz))

Modified: felix/trunk/converter/serializer/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/pom.xml?rev=1784722&r1=1784721&r2=1784722&view=diff
==============================================================================
--- felix/trunk/converter/serializer/pom.xml (original)
+++ felix/trunk/converter/serializer/pom.xml Tue Feb 28 11:03:27 2017
@@ -101,7 +101,14 @@
             <artifactId>snakeyaml</artifactId>
             <version>1.17</version>
         </dependency>
-        
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.utils</artifactId>
+            <version>1.9.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>

Modified: felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java?rev=1784722&r1=1784721&r2=1784722&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
(original)
+++ felix/trunk/converter/serializer/src/main/java/org/apache/felix/serializer/impl/json/JsonDeserializingImpl.java
Tue Feb 28 11:03:27 2017
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Scanner;
 
 import org.apache.felix.serializer.impl.Util;
+import org.apache.felix.utils.json.JSONParser;
 import org.osgi.service.serializer.Deserializing;
 import org.osgi.util.converter.ConversionException;
 import org.osgi.util.converter.Converter;
@@ -41,7 +42,7 @@ public class JsonDeserializingImpl<T> im
     @Override
     @SuppressWarnings("unchecked")
     public T from(CharSequence in) {
-        JsonParser jp = new JsonParser(in);
+        JSONParser jp = new JSONParser(in);
         Map<?,?> m = jp.getParsed();
         if (type instanceof Class)
             if (m.getClass().isAssignableFrom((Class<?>) type))

Modified: felix/trunk/converter/serializer/src/test/java/org/apache/felix/serializer/impl/json/JsonParserTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/converter/serializer/src/test/java/org/apache/felix/serializer/impl/json/JsonParserTest.java?rev=1784722&r1=1784721&r2=1784722&view=diff
==============================================================================
--- felix/trunk/converter/serializer/src/test/java/org/apache/felix/serializer/impl/json/JsonParserTest.java
(original)
+++ felix/trunk/converter/serializer/src/test/java/org/apache/felix/serializer/impl/json/JsonParserTest.java
Tue Feb 28 11:03:27 2017
@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.felix.utils.json.JSONParser;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -31,7 +32,7 @@ public class JsonParserTest {
     @Test
     public void testJsonSimple() {
         String json = "{\"hi\": \"ho\", \"ha\": true}";
-        JsonParser jp = new JsonParser(json);
+        JSONParser jp = new JSONParser(json);
         Map<String, Object> m = jp.getParsed();
         assertEquals(2, m.size());
         assertEquals("ho", m.get("hi"));
@@ -50,7 +51,7 @@ public class JsonParserTest {
                 + "  ]\n"
                 + "}\n"
                 + "\n";
-        JsonParser jp = new JsonParser(json);
+        JSONParser jp = new JSONParser(json);
         Map<String, Object> m = jp.getParsed();
         assertEquals(2, m.size());
         assertEquals("ho", m.get("hi"));
@@ -69,7 +70,7 @@ public class JsonParserTest {
                 + "  ]\r\n"
                 + "}\r\n"
                 + "\r\n";
-        JsonParser jp = new JsonParser(json);
+        JSONParser jp = new JSONParser(json);
         Map<String, Object> m = jp.getParsed();
         assertEquals(2, m.size());
         assertEquals("ho", m.get("hi"));
@@ -80,7 +81,7 @@ public class JsonParserTest {
     @SuppressWarnings("unchecked")
     public void testJsonComplex() {
         String json = "{\"a\": [1,2,3,4,5], \"b\": {\"x\": 12, \"y\": 42, \"z\": {\"test
test\": \"hello hello\"}}, \"ddd\": 12.34}";
-        JsonParser jp = new JsonParser(json);
+        JSONParser jp = new JSONParser(json);
         Map<String, Object> m = jp.getParsed();
         assertEquals(3, m.size());
         assertEquals(Arrays.asList(1L, 2L, 3L, 4L, 5L), m.get("a"));
@@ -97,7 +98,7 @@ public class JsonParserTest {
     @Test
     public void testJsonArray() {
         String json = "{\"abc\": [\"x\", \"y\", \"z\"]}";
-        JsonParser jp = new JsonParser(json);
+        JSONParser jp = new JSONParser(json);
         Map<String, Object> m = jp.getParsed();
         assertEquals(1, m.size());
         assertEquals(Arrays.asList("x", "y", "z"), m.get("abc"));
@@ -106,7 +107,7 @@ public class JsonParserTest {
     @Test
     public void testEmptyJsonArray() {
         String json = "{\"abc\": {\"def\": []}}";
-        JsonParser jp = new JsonParser(json);
+        JSONParser jp = new JSONParser(json);
         Map<String, Object> m = jp.getParsed();
         assertEquals(1, m.size());
         Map<String, Object> result = new HashMap<>();

Modified: felix/trunk/utils/src/main/java/org/apache/felix/utils/json/JSONParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/utils/src/main/java/org/apache/felix/utils/json/JSONParser.java?rev=1784722&r1=1784721&r2=1784722&view=diff
==============================================================================
--- felix/trunk/utils/src/main/java/org/apache/felix/utils/json/JSONParser.java (original)
+++ felix/trunk/utils/src/main/java/org/apache/felix/utils/json/JSONParser.java Tue Feb 28
11:03:27 2017
@@ -76,7 +76,7 @@ public class JSONParser {
 
     public JSONParser(CharSequence json) {
         String str = json.toString();
-        str = str.trim().replace('\n', ' ');
+        str = str.trim().replace('\n', ' ').replace('\r', ' ');
         parsed = parseObject(str);
     }
 
@@ -329,4 +329,4 @@ public class JSONParser {
         }
         return new String(bytes, encoding);
     }
-}
\ No newline at end of file
+}



Mime
View raw message