Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@zerok
Created February 24, 2017 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerok/82d625165596dcaa0a333857a3da2c2d to your computer and use it in GitHub Desktop.
Save zerok/82d625165596dcaa0a333857a3da2c2d to your computer and use it in GitHub Desktop.
{
"type": "div",
"props": {
"className": "breadcrumbs breadcrumbs--wide"
},
"children": [
{
"type": "div",
"props": {
"className": "row expanded"
},
"children": [
{
"type": "div",
"props": {
"className": "columns"
},
"children": [
{
"type": "ul",
"props": null,
"children": [
{
"type": "li",
"props": {
"className": "breadcrumbs__item"
},
"children": [
{
"type": "a",
"props": {
"style": null
},
"children": [
{
"type": "i",
"props": {
"className": "fa fa-fw fa-home"
},
"children": null
},
" Home"
]
}
]
},
{
"type": "li",
"props": {
"className": "breadcrumbs__item"
},
"children": [
{
"type": "span",
"props": null,
"children": [
"label"
]
}
]
}
]
}
]
}
]
}
]
}
$..[?(@.type=="li")]

I basically want the first type==li item in that whole object.

The example works on http://jsonpath.com/ but Node's jsonpath returns into an endless recursion :(

    RangeError: Maximum call stack size exceeded

      at is_object (node_modules/jsonpath/lib/handlers.js:183:23)
      at Handlers.<anonymous> (node_modules/jsonpath/lib/handlers.js:210:18)
      at node_modules/jsonpath/lib/handlers.js:220:13
      at Array.forEach (native)
      at Handlers.<anonymous> (node_modules/jsonpath/lib/handlers.js:217:26)
      at node_modules/jsonpath/lib/handlers.js:220:13
      at Array.forEach (native)
      at Handlers.<anonymous> (node_modules/jsonpath/lib/handlers.js:217:26)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment