android - Parse json's element that can be different types using gson -


i have json object inside can have property can array or boolean value. question how can parse json without having issues while parsing it?

here im talking about:

 {         "offerid": "24",         "image1": "1452678081_56961bc195cf8.jpg",         "image2": "1452678081_56961bc195f38.jpg",         "image3": "1452678081_56961bc196124.jpg",         "featured": false,         "hide_button": false,         "categoryid": "1",         "locations": [             {                 "address": "problemveien 13, 0313 oslo",                 "long": "10.722052800000029",                 "latitude": "59.9409999"             },             {                 "address": "akersgata 68, 0180 oslo",                 "long": "10.744572199999993",                 "latitude": "59.9174608"             },             {                 "address": "trimveien 4, 0372 oslo",                 "long": "10.724201200000039",                 "latitude": "59.9466293"             },             {                 "address": "sandakerveien 116, 0484 oslo",                 "long": "10.769448300000022",                 "latitude": "59.9483484"             },             {                 "address": "vulkan 15, 0178 oslo",                 "long": "10.75169040000003",                 "latitude": "59.9223593"             }         ]     } 

and how object looks when doesnt have locations array inside:

{         "offerid": "25",         "image1": "1452678113_56961be1d6774.jpg",         "image2": "1452678113_56961be1d694f.jpg",         "image3": "1452678113_56961be1d6ae0.jpg",         "featured": false,         "hide_button": false,         "categoryid": "1",         "locations": false     } 

so once again, how can parse locations element because can boolean or array? there way parse using google gson?

thanks

i don't understand want, try this. can parse json objects, have check type , cast when locations.

class javabean {     object locations; } 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo