Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.2, 2.3.6, 2.4.0
-
Linux, Ubuntu Trusty 64 Bit, OpenJDK 7
Description
When creating JSON from maps, the keys are not properly quoted. The result ist invalid JSON.
Example code:
def o = [ 'a "Test"': "test1", 'test2': 'Test "2"' ] println JsonOutput.toJson(o) println JsonOutput.prettyPrint(JsonOutput.toJson(o))
Example code output:
{"a "Test"":"test1","test2":"Test \"2\""}
Caught: groovy.json.JsonException: Lexing failed on line: 1, column: 6, while reading 'T', no possible valid JSON value or punctuation could be recognized.
As you see, 'Test "2"' is being quoted correctly, but 'a "Test"' is not. The pretty printing fails parsing the invalid JSON in the second println line.
This happens with JsonBuilder as well.
Attachments
Issue Links
- is duplicated by
-
GROOVY-7331 JsonOutput does not escape double quotes in map keys
- Closed
- is superceded by
-
GROOVY-11314 JsonOutput Pretty Print always escapes characters
- Closed