groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pascalschumac...@apache.org
Subject incubator-groovy git commit: GROOVY-7127 - Allow isJsonDate to accept a date in format "yyyy-MM-ddThh:mm:ss+0000" since this is how the JsonOutput.toJson method formats a date in Groovy. JSON does not have a standard string output per the ECMA spec so bo
Date Fri, 26 Jun 2015 15:19:57 GMT
Repository: incubator-groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X a8313c3af -> c7facdc1f


GROOVY-7127 - Allow isJsonDate to accept a date in format "yyyy-MM-ddThh:mm:ss+0000" since
this is how the JsonOutput.toJson method formats a date in Groovy. JSON does not have a standard
string output per the ECMA spec so both may be accepted. (closes #45)


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

Branch: refs/heads/GROOVY_2_4_X
Commit: c7facdc1f13648731fba7fdfd5886b15d8e5037a
Parents: a8313c3
Author: bpaulin <bpaulin@BOB_PAULIN>
Authored: Thu Jun 25 20:01:35 2015 -0500
Committer: pascalschumacher <pascalschumacher@gmx.net>
Committed: Fri Jun 26 17:13:58 2015 +0200

----------------------------------------------------------------------
 .../src/main/java/groovy/json/internal/Dates.java           | 2 +-
 .../src/test/groovy/groovy/json/JsonSlurperTest.groovy      | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/c7facdc1/subprojects/groovy-json/src/main/java/groovy/json/internal/Dates.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json/src/main/java/groovy/json/internal/Dates.java b/subprojects/groovy-json/src/main/java/groovy/json/internal/Dates.java
index 1eb6b29..1fd49fe 100644
--- a/subprojects/groovy-json/src/main/java/groovy/json/internal/Dates.java
+++ b/subprojects/groovy-json/src/main/java/groovy/json/internal/Dates.java
@@ -175,7 +175,7 @@ public class Dates {
             return false;
         }
 
-        valid &= (charArray[start + 19] == '.');
+        valid &= (charArray[start + 19] == '.' || charArray[start + 19] == '+');
 
         if (!valid) {
             return false;

http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/c7facdc1/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperTest.groovy b/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperTest.groovy
index 3086fd3..95f52ca 100644
--- a/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperTest.groovy
+++ b/subprojects/groovy-json/src/test/groovy/groovy/json/JsonSlurperTest.groovy
@@ -308,4 +308,13 @@ class JsonSlurperTest extends GroovyTestCase {
         assert slurper.parse('{"a":true}'.bytes) == [a: true]
 
     }
+
+    void testJsonDate() {
+        def o = new JsonSlurper().
+            setType(JsonParserType.INDEX_OVERLAY).
+            setCheckDates(true).
+            parseText(JsonOutput.toJson([a : new Date()]))
+
+        assertEquals(Date.class, o.a.class)
+    }
 }


Mime
View raw message