Ivonhoe / google-gson

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

gson does not convert map of JSONObject correctly #553

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create map<String,Object> where String is key and Object is valid JSONObject
2. gson.toJson(map)
3. produces extra 'map' structures

What is the expected output? What do you see instead?

{
    "data": {
            "sender": {
                    "id": "blah",
                    "preferences": {
                    }
                }
            },
            "recipients": {
                    "userid": "2",
                    "type": "GUEST"
                }
            }
        }
    }
}

but getting

{
    "data": {
        "map": {
            "sender": {
                "map": {
                    "id": "blah",
                    "preferences": {
                        "map": {}
                    }
                }
            },
            "recipients": {
                "map": {
                    "userid": "2",
                    "type": "GUEST"
                }
            }
        }
    }
}
What version of the product are you using? On what operating system?
latest, centos

Please provide any additional information below.

Original issue reported on code.google.com by divinefa...@gmail.com on 21 Jan 2014 at 6:03

GoogleCodeExporter commented 9 years ago
while searching, i found out that it is due to how JSONObject is implemented. 
but having 'map' as wrapper when converted to json does not seem to make sense. 
please reconsider.

Original comment by divinefa...@gmail.com on 21 Jan 2014 at 6:05