I have a following JSON structure
{
"entity": {
"bsid": "8452",
"name": "Name limited",
"contact": "CONTACT",
"imgurl": "http://testlocalhost.com/",
},
"doc": {
"details": {
"bsid": "8452",
"type": "pdf"
}
"name": "estimates",
}
}
I need to find if bsid is present in the JSON structure. An important point to note is that the structure may change. However, what is guaranteed is bsid field will be present somewhere in the structure which I need to find and if present, get its value(8452 in this case. The value will be same everywhere it's present)
Since I am using google gson library, I know this can be achieved with the following statement:
jsonObject.getAsJsonObject("entity").get("bsid")
Here jsonObject is actually JsonObject of google gson which holds the above structure
However, as I mentioned the structure may change and bsid may not be present directly under entity. Hence I need a way to find a field in the structure globally.
Just need to walk the json and find the value.