You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2015/06/26 17:13:23 UTC
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
Repository: incubator-groovy
Updated Branches:
refs/heads/master b3baf6410 -> 9aaab940f
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/9aaab940
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/9aaab940
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/9aaab940
Branch: refs/heads/master
Commit: 9aaab940f17a2e36665255665267857d262111b0
Parents: b3baf64
Author: bpaulin <bp...@BOB_PAULIN>
Authored: Thu Jun 25 20:01:35 2015 -0500
Committer: pascalschumacher <pa...@gmx.net>
Committed: Fri Jun 26 17:09:14 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/9aaab940/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 cdde3f7..75c8a91 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/9aaab940/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)
+ }
}