Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xavier/json_pointer
Implementation of RFC 6901 which defines a string syntax for identifying a specific value within a JSON document
https://github.com/xavier/json_pointer
Last synced: 3 months ago
JSON representation
Implementation of RFC 6901 which defines a string syntax for identifying a specific value within a JSON document
- Host: GitHub
- URL: https://github.com/xavier/json_pointer
- Owner: xavier
- License: apache-2.0
- Created: 2015-04-18T11:26:01.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-10-11T18:15:59.000Z (over 5 years ago)
- Last Synced: 2024-10-12T16:52:49.725Z (3 months ago)
- Language: Elixir
- Size: 15.6 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Implementation of RFC 6901 which defines a string syntax for identifying a specific value within a JSON document. (JSON)
- fucking-awesome-elixir - json_pointer - Implementation of RFC 6901 which defines a string syntax for identifying a specific value within a JSON document. (JSON)
- awesome-elixir - json_pointer - Implementation of RFC 6901 which defines a string syntax for identifying a specific value within a JSON document. (JSON)
README
# JSON Pointer
An implementation of [RFC 6901](https://tools.ietf.org/html/rfc6901) which defines a string syntax for identifying a specific value within a JSON document.
## Installation
Add a dependency to your project `mix.exs`:
```Elixir
def deps do
[{:json_pointer, "~> 0.1.0"}]
end```
## Usage
```Elixir
document = %{
"key" => "value",
"list" => [1, 2, 3],
"deeply" => %{
"nested" =>
%{"values" => [
%{"x" => 1},
%{"x" => 2}
]
}
}
}JSONPointer.resolve(document, "/key")
# => {:ok, "value"}
JSONPointer.resolve(document, "/list/1")
# => {:ok, 2}
JSONPointer.resolve(document, "/deeply/nested/values/0")
# => {:ok, %{"x" => 1}}
JSONPointer.resolve(document, "/deeply/nested/values/1/x")
# => {:ok, 2}
JSONPointer.resolve(document, "/list/4")
# => {:error, "index 4 out of bounds in [1, 2, 3]"}```
## Dependencies
This library works with deserialized documents and does not include a JSON parser.
## Contributors
In order of appearance:
- [Xavier Defrang](https://github.com/xavier)
- [Dmitrii Dimandt](https://github.com/dmitriid)
- [Roman Heinrich](https://github.com/mindreframer)