I would like to parse data from JSON which is String type. I am using Google Gson. I'm wondering how can I get "OriginalTerm" and "FirstTranslation" information of this Json String:
{
"term0" : {
"PrincipalTranslations" : {
"0" :{
"OriginalTerm" : { "term" : "cat", "POS" : "n", "sense" : "domestic animal", "usage" : ""},
"FirstTranslation" : {"term" : "gato", "POS" : "nm", "sense" : " "}, "Note" : ""},
"1" :{
"OriginalTerm" : { "term" : "cat", "POS" : "n", "sense" : "member of cat family", "usage" : ""},
"FirstTranslation" : {"term" : "felino", "POS" : "nm", "sense" : "familia de animales"}, "Note" : ""}},
"AdditionalTranslations" : {
"0" :{
"OriginalTerm" : { "term" : "cat", "POS" : "n", "sense" : "guy", "usage" : "slang"},
"FirstTranslation" : {"term" : "tío, tipo, chaval", "POS" : "nm", "sense" : "coloq"},
"SecondTranslation" : {"term" : "vato", "POS" : "", "sense" : "Mex"}, "Note" : ""},
"original" : {
"Compounds" : {
"0" :{
"OriginalTerm" : { "term" : "alley cat", "POS" : "n", "sense" : "stray cat", "usage" : ""},
"FirstTranslation" : {"term" : "gato callejero", "POS" : "nm", "sense" : ""}, "Note" : ""},
"Lines" : "End Reached", "END" : true
}
I tried following these information but I can't solve it:
http://albertattard.blogspot.com.es/2009/06/practical-example-of-gson.html
JSON parsing using Gson for Java
I tried to serialized using GSON using POJO but I can't find the right structure, I tried using JsonObject too, jumping through object keys like "term0","PrincipalTranslations" but I have some trouble when I've multiple results for the same key, for example:
"0" :{
"OriginalTerm"....
"FirstTranslation"...
"1" :{
"OriginalTerm"....
"FirstTranslation"...
}
Thank you for advance.