I have a json object that inside can have a property that can be array or a boolean value. So my question is how can I parse this json without having issues while parsing it?
Here is what 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 this is how the object looks when it doesnt have the 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 I parse the locations
element because it can be a boolean or a array? Is there a way to parse this using google gson?
Thanks