I have a following array:
['/1', '/1/a', '/1/a/b', '/2', '/2/a', '/2/a/b']
I want to write a function which can return following:
['/1', '/2']
Actually '/1' means parent and '/1/a' means child. Let say we have following json:
[
{
a:{
b: 'b value'
}
}
{
a:{
b: 'b value'
}
}
{
a:{
b: 'b value'
}
}
]
If array is e.g.
['/1/a', '/1/a/b', '/2/a', '/2/a/b']
The function would return following:
['/1/a', '/2/a']
I run jsonpath function it returned the above array. I want to e.g change color of the objects returned from jsonpath.I am displaying json in browser using react, I want to only change the color of parent(i.e.'/1', '/2' ) not the children(i.e. '/1/a', '/1/a/b') to save extra renders, how can I do this? The function could be something like;
filter(val => !val.startsWith(parent))
How can I do this? Please help