fyhack / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

setPrettyPrinting cause missing comma deliminator after an empty map #153

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
if Gson instance is obtained from GsonBuilder with pretty print 
        GsonBuilder builder = new GsonBuilder();
        builder.setPrettyPrinting();
        Gson gson = builder.create();        
it would produce un-parseable json string if the object contains an empty map
example:
{"viewsStale":true,"fireAllRules":0,"formRules":[],"dcs":[{"accountId":1,
      "createdBy":"","name":"dc1","m_segmentGroup":{"accountId":1,
        "nextRuleId":0,"name":"dc1","createdBy":"","rules":{}"description":
        "desc"},"m_dcmTexts":{}}],"dispatchableName":"disp1","typeCode":-1,
  "subType":"GENERIC","name":"disp1","status":"A"}

notice missing comma here ("rules":{}"description":)

correct output without pretty print
{"viewsStale":true,"fireAllRules":0,"formRules":[],"dcs":[{"accountId":1,"create
dBy":"","name":"dc1","m_segmentGroup":{"accountId":1,"nextRuleId":0,"name":"dc1"
,"createdBy":"","rules":{},"description":"desc"},"m_dcmTexts":{}}],"dispatchable
Name":"disp1","typeCode":-1,"subType":"GENERIC","name":"disp1","status":"A"}

What version of the product are you using? On what operating system?
latest product. java: 1.6, os: xp

Please provide any additional information below.

Original issue reported on code.google.com by jackwum...@gmail.com on 2 Sep 2009 at 9:13

GoogleCodeExporter commented 9 years ago
Fixed in r454

Original comment by inder123 on 29 Sep 2009 at 5:53