0

I'm working with a RESTful webservice in android, and I'm using Spring for Android with Jackson for the first time.

I'm using this generator to generate the java classes, but I'm in trouble sometimes when an array of the same objects inside JSON have a different names:

"a2e4ea4a-0a29-4385-b510-2ca6df65db1c": {
                        "url": "//url1.jpg",
                        "ext": "jpg",
                        "name": "adobe xm0 ",
                        "children": {},
                        "tree_key": []
                    },
                    "d3ff3921-e084-4812-bc49-6a7431b6ce52": {
                        "url": "https://www.youtube.com/watch?v=myvideo",
                        "ext": "video",
                        "name": "youtube example",
                        "children": {},
                        "tree_key": []
                    },
                    "151b5d60-8f41-4f38-8b67-fe875c3f0381": {
                        "url": "https://vimeo.com/channels/staffpicks/something",
                        "ext": "video",
                        "name": "vimeo example",
                        "children": {},
                        "tree_key": []
                    }

All the 3 nodes are of the same kind and can be mapped with the same object, but the generator creates 3 classes for each node with different name.

Thanks for the help.

svprdga
  • 2,171
  • 1
  • 28
  • 51
  • This is not a JSON array, it's a JSON object. You must be printing out the array as object, thus Jackson puts object hash code as key and value as the object itself. – mtyurt Apr 15 '15 at 08:28

1 Answers1

0

With Jackson, you can use Map map = new ObjectMapper().readValue(<insert object here>, Map.class);

as mentioned by Programmer Bruce : here

Community
  • 1
  • 1
reidzeibel
  • 1,622
  • 1
  • 19
  • 24