I am facing an issue while looping through a JSON object. The presence of strings in the JSON is causing the loop to fail. How can I iterate only through the objects in the JSON without affecting the loop?
My main goal is to iterate through the objects contained within the JSON.
- I attempted
if(json.length!=3)
but encountered failure when reaching the object, presumably due to the lack of length property for the object - Another approach was using
, which failed at encountering the string "and"json.hasOwnProperty("field_id")
- Using
if(json.length=undefined)
also did not work as the length ended up becoming undefined itself
Below is my JSON data:
[
{
"field_id": 122,
"operator_id": "1",
"where_flag": true
"and",
{
"field_id": 128,
"operator_id": "0",
"where_flag": true
},
"and",
{
"field_id": 148,
"operator_id": "1",
"where_flag": true
}
]