Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.8.6
-
None
Description
I suppose that json text filtered with groovy.json.JsonOutput.prettyPrint should produce again valid JSON string. Try this example/testcase and see how prettyPrint breaks escaped characters:
String json = new groovy.json.JsonBuilder('a': 'x"y').toString() String pretty = groovy.json.JsonOutput.prettyPrint(json) // comment this println in final test case println json println pretty def slurper = new groovy.json.JsonSlurper() // this is OK in 1.8.6 try { def test1 = slurper.parseText(json) assert 'x"y' == test1.a } catch(Exception e) { assert false, "parsing generated JSON failed" } // this fails in 1.8.6 try { def test = slurper.parseText(pretty) println test.a } catch(Exception e) { assert false, "parsing pretty printed JSON failed" }