- Notifications
You must be signed in to change notification settings - Fork1
Converts JSONPath selectors into Access selectors
License
vrcca/json_path_access
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This library converts JSONPath expressions into Access list. This is really useful when you want to use it withget_in/2,drop_in/2, etc.
Assuming we have this JSON:
{"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 } }}You could access some fields using JSONPath selectors:
json_path=JsonPathAccess.to_access("$.store.bicycle.price")get_in(json,json_path)json_path=JsonPathAccess.to_access("$.store.book[1]['category']")get_in(json,json_path)
Ifavailable in Hex, the package can be installedby addingjson_path_access to your list of dependencies inmix.exs:
defdepsdo[{:json_path_access,"~> 0.1.0"}]end
Documentation can be generated withExDocand published onHexDocs. Once published, the docs canbe found athttps://hexdocs.pm/json_path_access.
This library attempts to implement this version of the spec:https://www.ietf.org/archive/id/draft-ietf-jsonpath-base-05.html
- Root Selector
- Dot Selector
- Dot Wildcard Selector
- Index Selector
- Index Wildcard Selector
- Array Slice Selector
- Note: Currently there is no support for negative steps.
- Filter Selector
- Descendant Selector
- List Selector
About
Converts JSONPath selectors into Access selectors
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.