Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Converts JSONPath selectors into Access selectors

License

NotificationsYou must be signed in to change notification settings

vrcca/json_path_access

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Example

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)

Installation

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.

TODO

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

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp