|
1 | | -ODGN JSONPointer |
2 | | -================= |
| 1 | +# ODGN JSONPointer |
| 2 | + |
3 | 3 | [](https://travis-ci.org/odogono/elixir-jsonpointer) |
4 | 4 | [](https://hex.pm/packages/odgn_json_pointer) |
5 | | - |
| 5 | +[](https://hex.pm/packages/odgn_json_pointer) |
| 6 | +[](https://hexdocs.pm/odgn_json_pointer/) |
| 7 | +[](https://hex.pm/packages/odgn_json_pointer) |
| 8 | +[](https://github.com/odogono/elixir-jsonpointer/blob/master/LICENSE.md) |
| 9 | +[](https://github.com/odogono/elixir-jsonpointer/commits/master) |
6 | 10 |
|
7 | 11 | An implementation of [JSON Pointer (RFC 6901)](http://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-08) for Elixir. |
8 | 12 |
|
9 | | - |
10 | 13 | ## Installation |
11 | 14 |
|
12 | 15 | Add a dependency to your project `mix.exs`: |
13 | 16 |
|
14 | | -```Elixir |
| 17 | +```elixir |
15 | 18 | def deps do |
16 | | - [{:odgn_json_pointer, "~> 3.0.1"}] |
| 19 | + [ |
| 20 | + {:odgn_json_pointer, "~> 3.1.0"} |
| 21 | + ] |
17 | 22 | end |
18 | 23 | ``` |
19 | 24 |
|
20 | 25 | ## Basic Usage |
21 | 26 |
|
22 | | -```Elixir |
| 27 | +```elixir |
23 | 28 | iex> JSONPointer.get( %{ "fridge" => %{ "door" => "milk" } }, "/fridge/door" ) |
24 | 29 | {:ok, "milk"} |
25 | 30 |
|
26 | | - |
27 | 31 | iex> JSONPointer.set( %{}, "/example/msg", "hello") |
28 | 32 | {:ok, %{ "example" => %{ "msg" => "hello" }}, nil } |
29 | 33 |
|
30 | | - |
31 | 34 | iex> JSONPointer.add( %{ "fridge" => [ "milk", "cheese" ]}, "/fridge/1", "salad") |
32 | 35 | {:ok, %{ "fridge" => [ "milk", "salad", "cheese" ]}, [ "milk", "cheese" ] } |
33 | 36 |
|
34 | | - |
35 | 37 | iex> JSONPointer.has?( %{ "milk" => true, "butter" => false}, "/butter" ) |
36 | 38 | true |
37 | 39 |
|
38 | | - |
39 | 40 | iex> JSONPointer.test( %{ "milk" => "skimmed", "butter" => false}, "/milk", "skimmed" ) |
40 | 41 | {:ok, %{ "milk" => "skimmed", "butter" => false} } |
41 | 42 |
|
42 | | - |
43 | 43 | iex> JSONPointer.remove( %{"fridge" => %{ "milk" => true, "butter" => true}}, "/fridge/butter" ) |
44 | 44 | {:ok, %{"fridge" => %{"milk"=>true}}, true } |
45 | 45 |
|
46 | | - |
47 | 46 | iex> JSONPointer.dehydrate( %{"a"=>%{"b"=>["c","d"]}} ) |
48 | 47 | {:ok, [{"/a/b/0", "c"}, {"/a/b/1", "d"}] } |
49 | 48 |
|
50 | | - |
51 | 49 | iex> iex> JSONPointer.hydrate( [ {"/a/1/b", "single"} ] ) |
52 | 50 | {:ok, %{"a" => %{"1" => %{"b" => "single"}}}} |
53 | 51 |
|
54 | | - |
55 | 52 | iex> JSONPointer.merge( %{"a"=>1}, %{"b"=>2} ) |
56 | 53 | {:ok, %{"a"=>1,"b"=>2} } |
57 | 54 |
|
58 | | - |
59 | 55 | iex> JSONPointer.transform( %{ "a"=>4, "b"=>%{ "c" => true }}, [ {"/b/c", "/valid"}, {"/a","/count", fn val -> val*2 end} ] ) |
60 | 56 | {:ok, %{"count" => 8, "valid" => true}} |
61 | | - |
62 | 57 | ``` |
63 | 58 |
|
64 | 59 | Full documentation can be found at https://hexdocs.pm/odgn_json_pointer. |
65 | 60 |
|
| 61 | +## Acknowledgement |
66 | 62 |
|
| 63 | +Inspiration from https://github.com/manuelstofer/json-pointer |
67 | 64 |
|
68 | | -## Ack |
69 | | - |
70 | | -inspiration from https://github.com/manuelstofer/json-pointer |
71 | | - |
72 | | -made without peeking (much) at the source of https://github.com/xavier/json_pointer |
| 65 | +Made without peeking (much) at the source of https://github.com/xavier/json_pointer |
73 | 66 |
|
74 | 67 | Made in Exeter, UK. |
75 | 68 |
|
76 | 69 |
|
77 | | -## License |
| 70 | +## Copyright and License |
| 71 | + |
| 72 | +Copyright (c) 2024 Alexander Veenendaal |
78 | 73 |
|
79 | | -This software is licensed under [the MIT license](LICENSE.md). |
| 74 | +This work is free. You can redistribute it and/or modify it under the |
| 75 | +terms of the MIT License. See the [LICENSE.md](./LICENSE.md) file for more details. |
0 commit comments