My favorites | Sign in
Project Logo
Project hosting will be READ-ONLY Wednesday at 8am PST due to brief network maintenance.
             
New issue | Search
for
| Advanced search | Search tips
Issue 153: setPrettyPrinting cause missing comma deliminator after an empty map
2 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Sep 29
Type-Defect
Priority-Medium
Milestone-Release1.4


Sign in to add a comment
 
Reported by jackwumail, Sep 02, 2009
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,"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"}

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.

Comment 1 by inder123, Sep 29, 2009
Fixed in r454
Status: Fixed
Labels: Milestone-Release1.4
Sign in to add a comment

Hosted by Google Code