I have the following object with nested objects in array's.
{
"network": {
"name": "Internet",
"properties": {
"reachable": true,
"ip": "google.com"
},
"children": [
{
"name": "router",
"properties": {
"reachable": true,
"ip": "10.0.0.1"
},
"children": [
{
"name": "switch1",
"properties": {
"reachable": true,
"ip": "10.0.0.2"
},
"children": [
{
"name": "switch2",
"properties": {
"reachable": true,
"ip": "10.0.0.3"
},
"children": [
{
"name": "computer1",
"properties": {
"reachable": true,
"ip": "10.0.0.217"
}
},
{
"name": "computer2",
"properties": {
"reachable": true,
"ip": "10.0.0.200"
}
}
]
},
{
"name": "some bridge",
"properties": {
"ip": "10.0.0.202",
"reachable": true
}
}
]
},
{
"name": "AP",
"properties": {
"reachable": true,
"ip": "10.0.0.230"
},
"children": [
{
"name": "Sonoff Bridge",
"properties": {
"ip": "10.0.0.26",
"reachable": true
}
},
{
"name": "sonoff2",
"properties": {
"ip": "10.0.0.27",
"reachable": true
}
}
]
}
]
}
]
},
"ipaddress": "10.0.0.2",
"state": false
}
I want to find/match ipaddress
to ip
in the network
object and set its reachable
value to the state
value.
(How) can I do this with jsonata ?
Reading the documentation I suspect I need to use the transform format ... ~> | ... | ... |
but I fail to grasp the concept.
The idea is to build a dynamic network map, eg: