I am confused that one time if single image there then I will get JSON response like this from my API,
{
"banners":
{
"imagepath": "myimg.jpg"
}
}
And if more than one image there then I get result like this,
{
"banners": {
"imagepath": [
"myimg.jpg",
"myimg1.jpg"
]
}
}
How do I handle both result at a same time using JSON parsing?
JSONObject.get("imagepath")andinstanceofto check of what type it is. Depending on the type you manually parse this variable.