{"id":13837628,"url":"https://github.com/fraunhoferfokus/JSum","last_synced_at":"2025-07-10T18:33:59.388Z","repository":{"id":16365740,"uuid":"79792157","full_name":"fraunhoferfokus/JSum","owner":"fraunhoferfokus","description":"Consistent checksum calculation of JSON objects.","archived":false,"fork":false,"pushed_at":"2024-06-17T01:36:16.000Z","size":119,"stargazers_count":91,"open_issues_count":2,"forks_count":9,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-16T11:08:27.011Z","etag":null,"topics":["checksum","hash","json-objects"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fraunhoferfokus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-23T10:00:04.000Z","updated_at":"2025-04-20T15:55:21.000Z","dependencies_parsed_at":"2022-07-22T07:02:00.390Z","dependency_job_id":null,"html_url":"https://github.com/fraunhoferfokus/JSum","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/fraunhoferfokus/JSum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraunhoferfokus%2FJSum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraunhoferfokus%2FJSum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraunhoferfokus%2FJSum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraunhoferfokus%2FJSum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fraunhoferfokus","download_url":"https://codeload.github.com/fraunhoferfokus/JSum/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraunhoferfokus%2FJSum/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264631212,"owners_count":23640941,"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":["checksum","hash","json-objects"],"created_at":"2024-08-04T15:01:17.762Z","updated_at":"2025-07-10T18:33:59.091Z","avatar_url":"https://github.com/fraunhoferfokus.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# JSum\nConsistent checksum calculation of JSON objects.\n\n[![Unit Tests](https://github.com/fraunhoferfokus/JSum/actions/workflows/node.js.yml/badge.svg)](https://github.com/fraunhoferfokus/JSum/actions/workflows/node.js.yml)\n\n## Quick start\n```js\nconst JSum = require('jsum')\n\nconst obj1 = {foo: [{c: 1}, {d: 2, e: 3}], bar: {a: 2, b: undefined}}\nconst obj2 = {bar: {b: undefined, a: 2}, foo: [{c: 1}, {e: 3, d: 2}]}\n\nconsole.log(JSum.digest(obj1, 'SHA256', 'hex')) // 9a08ad6302b1e9e5682c365c8b24c5ca2ea6db5c90b672bc5b579879136dda0c\nconsole.log(JSum.digest(obj2, 'SHA256', 'hex')) // 9a08ad6302b1e9e5682c365c8b24c5ca2ea6db5c90b672bc5b579879136dda0c\n```\n\n## Why this module?\nMy main goal was to create [`Etag`s](https://tools.ietf.org/html/rfc7232#section-2.3) from JSON objects. The most intuitive approach\nwould have been something like:\n\n```js\nconst crypto = require('crypto')\n\nfunction checksum (obj) {\n  return crypto.createHash('MD5').update(JSON.stringify(myObj)).digest('hex')\n}\n```\n\nHowever, this approach would yield two different results for semantically same JSON objects:\n\n```js\nconsole.log(checksum({\"a\": 1, \"b\": 2})) // 608de49a4600dbb5b173492759792e4a\nconsole.log(checksum({\"b\": 2, \"a\": 1})) // 9915965eb40d343a8fe26e4e341d1a05\n```\n\n`JSum` on other hand makes sure that semantically same JSON objects always get the same checksum! Moreover, it provides a good deal\nof time advantage over some other viable modules\\*:\n\n| Module                  | Time (ms) to hash a 181 MB JSON file (from memory) |\n|-------------------------|:---------------------------------------------------:|\n| `json-hash`             | `81537`                                             |\n| `json-stable-stringify` | `12134`                                             |\n| `JSum`                  | `7200`                                              |\n| `json-checksum`         | `FATAL ERROR: [...] - process out of memory`        |\n\n\nFor this trivial test a huge [random JSON file](https://github.com/zemirco/sf-city-lots-json)\n(181 MB) was taken as the base for benchmarking. The listed modules were used to create `SHA256` hash of that file. To measure the time,\ninternal `console.time(()` and `console.timeEnd()` methods were used. Serious benchmarking is described below.\n\n## Benchmarking\nYou can also run benchmarks to compare performance with similar modules:\n\n```bash\nnpm i --no-save \\\n  benchmarked \\\n  fast-json-stable-stringify \\\n  json-checksum json-hash \\\n  json-stable-stringify\nnode benchmark/index.js\n```\n\nResults:\n\n```\n# benchmark/fixtures/medium.json (77986 bytes)\n  fast-json-stable-stringify x 1,191 ops/sec ±1.11% (89 runs sampled)\n  json-checksum x 406 ops/sec ±2.04% (89 runs sampled)\n  json-hash x 148 ops/sec ±2.08% (75 runs sampled)\n  json-stable-stringify x 1,051 ops/sec ±2.29% (88 runs sampled)\n  jsum x 1,339 ops/sec ±0.77% (93 runs sampled)\n\n  fastest is jsum\n\n# benchmark/fixtures/small.json (456 bytes)\n  fast-json-stable-stringify x 116,709 ops/sec ±2.25% (91 runs sampled)\n  json-checksum x 36,311 ops/sec ±1.66% (91 runs sampled)\n  json-hash x 12,051 ops/sec ±3.62% (77 runs sampled)\n  json-stable-stringify x 91,078 ops/sec ±2.08% (89 runs sampled)\n  jsum x 116,130 ops/sec ±1.46% (90 runs sampled)\n\n  fastest is jsum\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraunhoferfokus%2FJSum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffraunhoferfokus%2FJSum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraunhoferfokus%2FJSum/lists"}