Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/impatienttraveller/json-tools
An implementation of RFC-6901 and RFC-6902 in Crystal Lang
https://github.com/impatienttraveller/json-tools
Last synced: 3 months ago
JSON representation
An implementation of RFC-6901 and RFC-6902 in Crystal Lang
- Host: GitHub
- URL: https://github.com/impatienttraveller/json-tools
- Owner: impatienttraveller
- License: mit
- Created: 2019-02-09T19:54:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-10T16:41:03.000Z (about 5 years ago)
- Last Synced: 2024-08-01T17:33:28.701Z (6 months ago)
- Language: Crystal
- Size: 38.1 KB
- Stars: 17
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
- awesome-crystal - JSON tools - An implementation of JSON Patch and Pointer RFC's (Data Formats)
README
# json-tools
[![Built with Crystal](https://img.shields.io/badge/built%20with-crystal-000000.svg?style=flat-square)](https://crystal-lang.org/)
[![Build Status](https://travis-ci.org/impatienttraveller/json-tools.svg?branch=master)](https://travis-ci.org/impatienttraveller/json-tools)
[![Releases](https://img.shields.io/github/release/impatienttraveller/json-tools.svg?style=flat-square)](https://github.com/impatienttraveller/json-tools/releases)An implementation of [RFC-6901](https://tools.ietf.org/html/rfc6901) and [RFC-6902](https://datatracker.ietf.org/doc/rfc6902)
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
json-tools:
github: impatienttraveller/json-tools
```## Usage
```crystal
require "json-tools"
```Once you have a `JSON::Any` object in memory you can address any value using the `Pointer` class:
```crystal
json : JSON::Any = ...
val = Json::Tools::Pointer.new("/foo/0/bar").eval(json)
```JSON object can be patched by using the `Patch` class:
```crystal
patch : JSON::Any = ...
json : JSON::Any = ...
patched_json = Json::Tools::Patch.new(patch).apply(json)
```This creates a copy of the passed JSON object to work with and the original object is not altered.
## Development
Please raise a GitHub issue and document the commit with the following format:
```
[issue-x] Description
```## Contributing
1. Fork it ()
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
- [ddcprg](https://github.com/ddcprg) Daniel del Castillo - creator, maintainer