Converting a complex json object to java object through gson?

And your container class could have a private List tags.

Up vote 0 down vote favorite share g+ share fb share tw.

I've a problem with storing a Json object as a java object, I'm not sure what structure to use to store something like this: 'tags':{'CouchDB':1},{'JSON':1},{'database':1},{'NoSQL':1},{'document_database':1} I have tried 2 dimensional arrays, ArrayLists and Hashtables but didn't work, could be down to my poor implementation or I just have it wrong, need help with this ASAP please! I'm using GSON to convert from the Json String to the Java object, and have other parts working fine, the problem is just having GSON parse this structure properly java json gson link|improve this question asked Aug 3 '11 at 14:29John 31.

Try using jsonlint.com/ to make sure that your JSON is valid (it doesn't seem to be) If you change your tags to {"name":"couchdb"}, your Java class could look like this: public class Tag { private String name; ... } And your container class could have a private List tags.

Thanks Mike that's what I did in the end and it works perfectly now, (I used an ArrayList of Tag objects in case anyone's curious though) – John Aug 5 '11 at 10:24.

Seems, like your tags are just a bunch of keys with a count (or something along those lines) attached to each one, i.e. Key-value pairs which is just a hashtable e.g. : {'tags':{'CouchDB':1,'JSON':1,'database':1,'NoSQL':1,'document_database':1}} You should be able to convert the above without any trouble, if you can't I would say you have some sort of configuration issue as opposed to any kind of problem with the format of the data.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions