{"id":20786225,"url":"https://github.com/dryruby/json-canonicalization","last_synced_at":"2025-05-05T15:50:46.023Z","repository":{"id":54516515,"uuid":"176341512","full_name":"dryruby/json-canonicalization","owner":"dryruby","description":"An implementation of the JSON Canonicalization Scheme for Ruby","archived":false,"fork":false,"pushed_at":"2023-12-08T02:30:15.000Z","size":107,"stargazers_count":8,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-04-27T00:33:12.295Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dryruby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-18T17:57:48.000Z","updated_at":"2024-10-29T01:00:01.000Z","dependencies_parsed_at":"2023-12-04T21:29:31.825Z","dependency_job_id":"cc6558ff-fe27-4cd0-b7de-847c125402af","html_url":"https://github.com/dryruby/json-canonicalization","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":0.04347826086956519,"last_synced_commit":"7098e844cbd64f8a2380aec6dedfaaa7af662169"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dryruby%2Fjson-canonicalization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dryruby%2Fjson-canonicalization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dryruby%2Fjson-canonicalization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dryruby%2Fjson-canonicalization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dryruby","download_url":"https://codeload.github.com/dryruby/json-canonicalization/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252526421,"owners_count":21762498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T14:51:14.652Z","updated_at":"2025-05-05T15:50:45.995Z","avatar_url":"https://github.com/dryruby.png","language":"Ruby","readme":"# json-canonicalization\nAn implementation of the JSON Canonicalization Scheme for Ruby\n\nImplements [RFC8785](https://datatracker.ietf.org/doc/html/rfc8785) (JSON Canonicalization Scheme) in Ruby.\n\n[![Gem Version](https://badge.fury.io/rb/json-canonicalization.svg)](http://badge.fury.io/rb/json-canonicalization)\n[![Build Status](https://github.com/dryruby/json-canonicalization/workflows/CI/badge.svg?branch=develop)](https://github.com/dryruby/json-canonicalization/actions?query=workflow%3ACI)\n[![Coverage Status](https://coveralls.io/repos/dryruby/json-canonicalization/badge.svg)](https://coveralls.io/r/dryruby/json-canonicalization)\n\n# Description\n\nCryptographic operations like hashing and signing depend on that the target \ndata does not change during serialization, transport, or parsing. \nBy applying the rules defined by JCS (JSON Canonicalization Scheme), \ndata provided in the JSON [[RFC8259](https://tools.ietf.org/html/rfc8259)]\nformat can be exchanged \"as is\", while still being subject to secure cryptographic operations.\nJCS achieves this by building on the serialization formats for JSON\nprimitives as defined by ECMAScript [[ES6](https://www.ecma-international.org/ecma-262/6.0/index.html)],\nconstraining JSON data to the\u003cbr\u003eI-JSON [[RFC7493](https://tools.ietf.org/html//rfc7493)] subset,\nand through a platform independent property sorting scheme.\n\nRFC: https://datatracker.ietf.org/doc/html/rfc8785\n\nThe JSON Canonicalization Scheme concept in a nutshell:\n- Serialization of primitive JSON data types using methods compatible with ECMAScript's `JSON.stringify()`\n- Lexicographic sorting of JSON `Object` properties in a *recursive* process\n- JSON `Array` data is also subject to canonicalization, *but element order remains untouched*\n\n### Sample Input:\n```code\n{\n  \"numbers\": [333333333.33333329, 1E30, 4.50,\n              2e-3, 0.000000000000000000000000001],\n  \"string\": \"\\u20ac$\\u000F\\u000aA'\\u0042\\u0022\\u005c\\\\\\\"\\/\",\n  \"literals\": [null, true, false]\n}\n```\n### Expected Output:\n```code\n{\"literals\":[null,true,false],\"numbers\":[333333333.3333333,1e+30,4.5,0.002,1e-27],\"string\":\"€$\\u000f\\nA'B\\\"\\\\\\\\\\\"/\"}\n```\n## Usage\nThe library accepts Ruby input and generates canonical JSON via the `#to_json_c14n` method. This is based on the standard JSON gem's version of `#to_json` with overloads for `Hash`, `String` and `Numeric`\n\n```ruby\ndata = {\n  \"numbers\" =\u003e [\n    333333333.3333333,\n    1.0e+30,\n    4.5,\n    0.002,\n    1.0e-27\n  ],\n  \"string\" =\u003e \"€$\\u000F\\nA'B\\\"\\\\\\\\\\\"/\",\n  \"literals\" =\u003e [nil, true, false]\n}\n\nputs data.to_json_c14n\n=\u003e \n```\n\n## Documentation\nFull documentation available on [GitHub](https://dryruby.github.io/json-canonicalization/)\n\n### Principal Classes\n* {JSON::Canonicalization}\n\n## Dependencies\n* [Ruby](http://ruby-lang.org/) (\u003e= 3.0)\n* [JSON](https://rubygems.org/gems/json) (\u003e= 2.6)\n\n## Author\n* [Gregg Kellogg](https://github.com/gkellogg) - \u003chttps://greggkellogg.net/\u003e\n\n## Contributing\n* Do your best to adhere to the existing coding conventions and idioms.\n* Don't use hard tabs, and don't leave trailing whitespace on any line.\n* Do document every method you add using [YARD][] annotations. Read the\n  [tutorial][YARD-GS] or just look at the existing code for examples.\n* Don't touch the `json-ld.gemspec`, `VERSION` or `AUTHORS` files. If you need to\n  change them, do so on your private branch only.\n* Do feel free to add yourself to the `CREDITS` file and the corresponding\n  list in the the `README`. Alphabetical order applies.\n* Do note that in order for us to merge any non-trivial changes (as a rule\n  of thumb, additions larger than about 15 lines of code), we need an\n  explicit [public domain dedication][PDD] on record from you,\n  which you will be asked to agree to on the first commit to a repo within the organization.\n\n## License\n\nThis is free and unencumbered public domain software. For more information,\nsee \u003chttps://unlicense.org/\u003e or the accompanying {file:LICENSE} file.\n\n[YARD]:           https://yardoc.org/\n[YARD-GS]:        https://rubydoc.info/docs/yard/file/docs/GettingStarted.md\n[PDD]:            https://unlicense.org/#unlicensing-contributions\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdryruby%2Fjson-canonicalization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdryruby%2Fjson-canonicalization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdryruby%2Fjson-canonicalization/lists"}