hana.cr

An implementation of JSON Patch and JSON Pointer for Crystal

hana

crystal port of ruby gem hana.

Implementation of JSON Patch and JSON Pointer RFC.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      hana:
        github: cyangle/hana.cr
        version: ~> 0.1.0
    
  2. 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

  1. Fork it (https://github.com/cyangle/hana.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

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