Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select parent of first element #35

Open
vjpr opened this issue May 22, 2015 · 2 comments
Open

Select parent of first element #35

vjpr opened this issue May 22, 2015 · 2 comments

Comments

@vjpr
Copy link

vjpr commented May 22, 2015

Just like in jsonpath.

@dfilatov
Copy link
Owner

Could you provide an example with data, query and result you want to get?

@vjpr
Copy link
Author

vjpr commented May 23, 2015

Useful with recursive/nested selectors.

jp.parent(obj, '..book')[0]

>>> <book array>
var obj = {
  "store": {
    "book": [ 
      {
        "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      }, {
        "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99
      }, {
        "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99
      }, {
         "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ],
    "bicycle": {
      "color": "red",
      "price": 19.95
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants