thingToClean = parseJSON(yourJSON)
thingToClean.offendingVariable = invalid
yourJSON = formatJSON(thingToClean)
arrayFromJSON = parseJSON(....)
arrayFromJSON.shift()
' or
arrayFromJSON.delete(0)
"rohitkaushik" wrote:
I want to delete a array from json.In this example , I want to delete first item whose groupName="Ungrouped".
}
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)
"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)
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)
"TheEndless" wrote:"RokuKC" wrote:
Assuming the Ungrouped item is not necessarily the first:
[code ... /]
That also assumes it's the only one in the array. If there are multiple, you can reverse the loop and do this:
[code ... /]
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.
"TheEndless" wrote:
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.
"TheEndless" wrote:
Well, would you look at that. They documented it, so I guess it is supported now!
"TheEndless" wrote:
In previous tests, we found that an AA with a circular reference would hang the box (for obvious reasons). Now that it's documented, it's possible they put checks in to prevent that.
"dcrandall" wrote:"TheEndless" wrote:
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.
"RokuKC" wrote:
ParseJSON and FormatJSON are supported functions for devices running modern firmware.
We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.
Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality.
In the meantime, for additional assistance, visit our Support Site.
Thanks for your patience — we’re excited to share what’s next!