{"id":28515952,"url":"https://github.com/thybag/json-api-rehydrate","last_synced_at":"2025-07-05T17:30:46.854Z","repository":{"id":57284699,"uuid":"87478244","full_name":"thybag/json-api-rehydrate","owner":"thybag","description":"A JS utility for turning a JSON:API response back in to a hierarchical data structure","archived":false,"fork":false,"pushed_at":"2017-09-08T13:13:12.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T03:37:22.837Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thybag.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-06T21:49:35.000Z","updated_at":"2018-05-08T23:06:19.000Z","dependencies_parsed_at":"2022-08-25T03:50:31.097Z","dependency_job_id":null,"html_url":"https://github.com/thybag/json-api-rehydrate","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/thybag/json-api-rehydrate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thybag%2Fjson-api-rehydrate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thybag%2Fjson-api-rehydrate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thybag%2Fjson-api-rehydrate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thybag%2Fjson-api-rehydrate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thybag","download_url":"https://codeload.github.com/thybag/json-api-rehydrate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thybag%2Fjson-api-rehydrate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263778281,"owners_count":23509967,"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":"2025-06-09T03:31:25.760Z","updated_at":"2025-07-05T17:30:46.842Z","avatar_url":"https://github.com/thybag.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON:API rehydrate\n\nJSON:API rehydrate is a small, fast, dependencyless utility for \"rehydrating\" (or deserializing) [json:api](http://jsonapi.org/) responses back in to hierarchical data structures for easier use on the front-end.\n\n## Installation\n\n 1. Download a copy of the `json-api-rehydrate.js`\n 2. Include the library in to your webpage.\n 3. Call it on your json:api payload `var data = jsonApiReHydrate.rehydrate( jsonApiPayload );`\n\nAlternately you can;\n\n* Install using NPM run `npm install json-api-rehydrate`\n* Install using Bower run `bower install json-api-rehydrate`\n\n## Basic usage\n\nBy default the `jsonApiReHydrate` will be added to the window object making it globally available. (Unless loaded via AMD or otherwise).\n\nTo rehydrate a response with the utility simply call its `rehydrate` method with the json:api response you would like to hydrate.\n\n```\n// response = myApi.fetch(\"some-json-api-endpoint\");\nvar data = jsonApiReHydrate.rehydrate(response);\nconsole.log(data);\n```\n\n## Example\n\nThe json:api response below\n\n```\n{\n\t\"data\": {\n\t\t\"type\": \"people\",\n\t\t\"id\": \"1\",\n\t\t\"attributes\": {\n\t\t\t\"name\": \"Dave\"\n\t\t},\n\t\t\"relationships\": {\n\t\t\t\"published\": {\n\t\t\t\t\"data\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"type\": \"books\",\n\t\t\t\t\t\t\"id\": \"1\"\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"type\": \"books\",\n\t\t\t\t\t\t\"id\": \"2\"\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t},\n\t\"included\": [\n\t\t{\n\t\t\t\"type\": \"books\",\n\t\t\t\"id\": \"1\",\n\t\t\t\"attributes\": {\n\t\t\t\t\"title\": \"Foo\",\n\t\t\t\t\"year\": 1991\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\t\"type\": \"books\",\n\t\t\t\"id\": \"2\",\n\t\t\t\"attributes\": {\n\t\t\t\t\"title\": \"Bar\",\n\t\t\t\t\"year\": 2015\n\t\t\t}\n\t\t}\n\t]\n}\n```\nWill produce the following output \n\n```\n{\n\t\"name\": \"Dave\",\n\t\"id\": \"1\",\n\t\"published\": [\n\t\t{\n\t\t\t\"title\": \"Foo\",\n\t\t\t\"year\": 1991,\n\t\t\t\"id\": \"1\"\n\t\t},\n\t\t{\n\t\t\t\"title\": \"Bar\",\n\t\t\t\"year\": 2015,\n\t\t\t\"id\": \"2\"\n\t\t}\n\t]\n}\n```\n## Additional features\n\nA number of additional functions are available on each of the objects \u0026 arrays return by the json-api-rehydrator, in order to provide\neasy access to the data in its original form.\n\n* Rehydrated objects provide `getOriginal()`, `getId()`,  `getType()`, `getMeta()`, `getLinks()`, `getRelationships()` and `getAttributes()`.\n* Rehydrated arrays provide `getOriginal()`, `getMeta()` and `getLinks()`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthybag%2Fjson-api-rehydrate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthybag%2Fjson-api-rehydrate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthybag%2Fjson-api-rehydrate/lists"}