cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Update basic JSON parser to handle null values
Date Tue, 23 Feb 2016 15:17:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/master ab05d4ee3 -> ac4e9af32


Update basic JSON parser to handle null values


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ac4e9af3
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ac4e9af3
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ac4e9af3

Branch: refs/heads/master
Commit: ac4e9af325e904a4c54f53463a93a3865f8d86ef
Parents: ab05d4e
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Feb 23 15:17:28 2016 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Feb 23 15:17:28 2016 +0000

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java  | 3 +++
 .../cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java     | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ac4e9af3/rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java
b/rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java
index a6d11b9..4595444 100644
--- a/rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java
+++ b/rt/rs/extensions/json-basic/src/main/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriter.java
@@ -35,6 +35,7 @@ import org.apache.cxf.helpers.IOUtils;
 
 
 public class JsonMapObjectReaderWriter {
+    private static final String NULL_VALUE = "null";
     private boolean format;
     
     public JsonMapObjectReaderWriter() {
@@ -219,6 +220,8 @@ public class JsonMapObjectReaderWriter {
             value = valueStr.substring(1, valueStr.length() - 1);
         } else if ("true".equals(valueStr) || "false".equals(valueStr)) {
             value = Boolean.valueOf(valueStr);
+        } else if (NULL_VALUE.equals(valueStr)) {
+            return null;
         } else {
             try {
                 value = Long.valueOf(valueStr);

http://git-wip-us.apache.org/repos/asf/cxf/blob/ac4e9af3/rt/rs/extensions/json-basic/src/test/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/json-basic/src/test/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java
b/rt/rs/extensions/json-basic/src/test/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java
index fc9dfee..5a20475 100644
--- a/rt/rs/extensions/json-basic/src/test/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java
+++ b/rt/rs/extensions/json-basic/src/test/java/org/apache/cxf/jaxrs/json/basic/JsonMapObjectReaderWriterTest.java
@@ -40,11 +40,12 @@ public class JsonMapObjectReaderWriterTest extends Assert {
     }
     @Test
     public void testReadMap() throws Exception {
-        String json = "{\"a\":\"aValue\",\"b\":123,\"c\":[\"cValue\"]}";
+        String json = "{\"a\":\"aValue\",\"b\":123,\"c\":[\"cValue\"],\"f\":null}";
         Map<String, Object> map = new JsonMapObjectReaderWriter().fromJson(json);
-        assertEquals(3, map.size());
+        assertEquals(4, map.size());
         assertEquals("aValue", map.get("a"));
         assertEquals(123L, map.get("b"));
         assertEquals(Collections.singletonList("cValue"), map.get("c"));
+        assertNull(map.get("f"));
     }
 }


Mime
View raw message