How to work with name-value pairs (JSON) in a variable array
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2019 11:51 AM
I have a variable that is a JSON array of name-value pairs. I want to iterate over the pairs and remove the empty/null values. Can I use the JsonNodeIterator feature for this? I cannot find the JsonNode class in my script includes (London).
Thoughts?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2019 02:21 PM
This might help: https://stackoverflow.com/questions/23774231/how-do-i-remove-all-null-and-empty-string-values-from-a-json-object/23774287

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2019 02:27 PM
I usually iterate through the json object and delete the key if the value is null, undefined or empty
for (var propName in jsonObj) {
if (jsonObj[propName] === null || jsonObj[propName] === undefined ||jsonObj[propName]=='' ) {
delete jsonObj[propName];
}
}