petritr
10 months ago

filter json object by keys

Posted 10 months ago by petritr

I need to filter json object by keys in js:

0: {id: "device_id.0", value: Array(1)}
1: {id: "device_id.1", value: Array(1)}
2: {id: "ip_address.0", value: Array(1)}
3: {id: "ip_address.1", value: Array(1)}

I need to filter it by keys if id key is 0 push to device 0 I need to achieve the following :

device.0 {
{id: "device_id.0", value: Array(1)}
{id: "ip_address.0", value: Array(1)}
}
device.1 {
{id: "device_id.1", value: Array(1)}
{id: "ip_address.1", value: Array(1)}
}

Please sign in or create an account to participate in this conversation.