I have the following array
{
"id": "parent",
"code": "parent",
"children": [
{
"id": "rtsp",
"code": "rtsp",
"children": [
{
"id": "001",
"code": "cam30",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "002",
"code": "cam31",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "003",
"code": "cam32",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "004",
"code": "cam10",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "005",
"code": "cam11",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "006",
"code": "cam12",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "007",
"code": "cam13",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "008",
"code": "cam14",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "009",
"code": "cam15",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "010",
"code": "cam16",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "011",
"code": "cam17",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "012",
"code": "cam18",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "013",
"code": "cam19",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "014",
"code": "cam9",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "015",
"code": "cam7",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "016",
"code": "cam8",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "017",
"code": "cam5",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
},
{
"id": "018",
"code": "cam6",
"source": "rtsp://192.168.43.29:8554/test",
"sourceFullScreen": "rtsp://192.168.43.29:8554/test"
}
]
},
{
"id": "test",
"code": "test",
"children": [
{
"id": "cam100",
"code": "cam100",
"source": "cam100",
"sourceFullScreen": "cam100"
},
{
"id": "zone-a",
"code": "zone-a",
"children": [
{
"id": "cam100a",
"code": "cam100a",
"source": "cam100a",
"sourceFullScreen": "cam100a"
}
]
},
{
"id": "cam101",
"code": "cam101",
"source": "changed",
"sourceFullScreen": "changed"
},
{
"id": "cam102",
"code": "cam102",
"source": "cam102",
"sourceFullScreen": "cam102"
},
{
"id": "cam103",
"code": "cam103",
"source": "cam102",
"sourceFullScreen": "cam102"
},
{
"id": "cam105",
"code": "cam105",
"source": "cam105",
"sourceFullScreen": "cam105"
}
]
},
{
"id": "entrepot",
"code": "entrepot",
"children": [
{
"id": "cam1100",
"code": "cam1100",
"source": "rtsp://125.122.15.12",
"sourceFullScreen": "rtsp://125.22.122.11"
},
{
"id": "safe zone",
"code": "safe zone",
"children": []
}
]
},
{
"id": "zsd",
"code": "sdf",
"children": []
},
{
"id": "za",
"code": "aze",
"children": []
},
{
"id": "qsd",
"code": "azeqsd",
"children": []
}
]
}
I want to write a function where given a code value it gives me back the full path. is there any arrays package with mæde function for this purpose
I tried the npm array-tools but no success a.where(json, { "id": idValue })
is giving an empty array, that I was hoping to show recursively.
what I need looks like
searchPath(array,"003") ==> "003,rtsp,parent"