Forum Discussion
TheEndless
11 years agoChannel Surfer
"RokuKC" wrote:"rohitkaushik" wrote:
I want to delete a array from json.In this example , I want to delete first item whose groupName="Ungrouped".
}
Assuming the Ungrouped item is not necessarily the first:j = ParseJSON(jsonStr)
for i = 0 to j.destinationContent.Count() - 1
item = j.destinationContent[ i ]
if item.groupName = "Ungrouped"
j.destinationContent.Delete(i)
exit for
end if
end for
newJsonStr = FormatJSON(j)
That also assumes it's the only one in the array. If there are multiple, you can reverse the loop and do this:
j = ParseJSON(jsonStr)
for i = j.destinationContent.Count() - 1 to 0 step -1
item = j.destinationContent[ i ]
if item.groupName = "Ungrouped"
j.destinationContent.Delete(i)
end if
end for
newJsonStr = FormatJSON(j)
It's also worth noting that FormatJSON isn't a supported function. If you use it in the wrong place, it could hang or crash the box.
Related Content
- 3 years ago
- 2 months ago