I have a SwiftyJSON array that is nested several levels and I need to filter the array based on a value in the lowest level. Below is an example of an array. I need to filter it on Active == true. What is the most efficient way to accomplish this?
var colors = JSON([
"Apple" : [
"Yellow" : [
"Active" : true,
"Working" : true,
"Value" : 0
],
"Red" : [
"Active" : false,
"Working" : true,
"Value" : 0
]
],
"Banana" : [
"Blue" : [
"Active" : false,
"Working" : true,
"Value" : 0
],
"Green" : [
"Active" : true,
"Working" : true,
"Value" : 0
]
]
])
Desired output:
"Apple" : [
"Yellow" : [
"Active" : true,
"Working" : true,
"Value" : 0
]
],
"Banana" : [
"Green" : [
"Active" : true,
"Working" : true,
"Value" : 0
]
]