Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Not A Problem
-
2.3.8
-
None
-
None
-
all ( tested on Linux x86_64, Ubuntu 14.4 & RHEL-6.6 )
Description
groovy.json.JsonSlurper exits with an error when parsing valid JSON :
$ groovy -e ' import groovy.json.*; println new JsonSlurper().parseText('"'"'"V":"\/"'"'"');' 14-Jan-2015 14:23:55 org.codehaus.groovy.runtime.m12n.MetaInfExtensionModule newModule WARNING: Module [groovy-nio] - Unable to load extension class [org.codehaus.groovy.runtime.NioGroovyMethods] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: script_from_command_line: 1: unexpected char: '\' @ line 1, column 66. JsonSlurper().parseText('"V":"\/"'); ^ 1 error
AFAICS, escaped chars ARE supported by the JSON Specification , as reported by
http://www.json.org :
"A string is a sequence of zero or more Unicode characters, wrapped in double
quotes, using backslash escapes."
Any occurrence of a back-slash escape sequence in a JSON string makes groovy fail
to parse the JSON, which is unfortunate, since my company's Microsoft web
application server translates all occurrences of the '/' character in JSON responses
to '\/', so we cannot use groovy to parse any of its JSON output.
Any chance of a standards-compliant JSON parser in groovy anytime soon, or do I
need to write my own ?