hana.cr
hana
crystal port of ruby gem hana.
Implementation of JSON Patch and JSON Pointer RFC.
Installation
-
Add the dependency to your
shard.yml
:dependencies: hana: github: cyangle/hana.cr version: ~> 0.1.0
-
Run
shards install
Usage
Example json patches in json:
[
{ "op": "add", "path": "/baz", "value": "qux" }
]
require "hana"
patch_json = File.read("/file/path/to/json_patches.json")
patch = Hana::Patch.new(patch_json)
doc = JSON.parse(%({"foo":"bar"}))
result = patch.apply(doc)
puts result.to_json # Outputs: {"foo":"bar","baz":"qux"}
Development
hana runs tests from json-patch/json-patch-tests. Fetch the git submodule by running:
git submodule init
git submodule update
Install dependencies with:
shards install
Then run the tests with:
crystal spec
Contributing
- Fork it (https://github.com/cyangle/hana.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Chao Yang - creator and maintainer
Repository
hana.cr
Owner
Statistic
- 0
- 0
- 0
- 0
- 1
- 23 days ago
- August 20, 2024
License
MIT License
Links
Synced at
Mon, 21 Oct 2024 08:36:51 GMT
Languages