{"id":16010334,"url":"https://github.com/amauryd/deno-json-api-deserializer","last_synced_at":"2026-04-26T23:31:40.078Z","repository":{"id":62422276,"uuid":"406537457","full_name":"AmauryD/deno-json-api-deserializer","owner":"AmauryD","description":"a deserializer for JSON:API payloads","archived":false,"fork":false,"pushed_at":"2021-09-16T21:25:31.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T12:04:26.266Z","etag":null,"topics":["backend","deno","deserializer","jsonapi","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/AmauryD.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}},"created_at":"2021-09-14T22:21:10.000Z","updated_at":"2021-10-16T19:19:29.000Z","dependencies_parsed_at":"2022-11-01T17:32:41.663Z","dependency_job_id":null,"html_url":"https://github.com/AmauryD/deno-json-api-deserializer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmauryD%2Fdeno-json-api-deserializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmauryD%2Fdeno-json-api-deserializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmauryD%2Fdeno-json-api-deserializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmauryD%2Fdeno-json-api-deserializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AmauryD","download_url":"https://codeload.github.com/AmauryD/deno-json-api-deserializer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247278662,"owners_count":20912768,"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":["backend","deno","deserializer","jsonapi","typescript"],"created_at":"2024-10-08T13:05:25.001Z","updated_at":"2026-04-26T23:31:40.046Z","avatar_url":"https://github.com/AmauryD.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# deno-json-api-deserializer [![Deno](https://github.com/AmauryD/deno-json-api-deserializer/actions/workflows/deno.yml/badge.svg)](https://github.com/AmauryD/deno-json-api-deserializer/actions/workflows/deno.yml)\n\nA backend deserializer for JSON:API payloads.\n\n## Features\n\n- Deserialize JSON:API payloads\n- Async\n- Highly modular with transforms functions\n- Filtering attributes/relationships\n\n## Examples\n\nSimple use\n\n```typescript\nimport { JsonApiDeserializer } from \"...\";\n\nconst deserializer = new JsonApiDeserializer();\nawait desserializer.deserialize({\n  data: {\n    attributes: {\n      title: \"test\",\n    },\n  },\n});\n```\n\ncamelCase deserializer with transforms\n\n```typescript\nconst deserializer = new JsonApiDeserializer();\n\nasync function main() {\n  /**\n   * For every transformation, we apply the camelCase function on the key\n   */\n  deserializer.transformAttributeFunction = (\n    key,\n    value,\n  ) =\u003e [camelCase(key), value];\n  deserializer.transformManyRelationshipFunction = (\n    key,\n    value,\n  ) =\u003e [camelCase(key), value.map((e) =\u003e e.id)];\n  deserializer.transformOneRelationshipFunction = (\n    key,\n    value,\n  ) =\u003e [camelCase(key), value];\n\n  const deserialized = await deserializer.deserialize({\n    data: {\n      attributes: {\n        title_test: \"test\",\n      },\n      relationships: {\n        people_comments: {\n          data: [\n            { type: \"comments\", id: \"9\" },\n            { type: \"comments\", id: \"10\" },\n          ],\n        },\n      },\n    },\n  });\n  // { id: undefined, peopleComments: [ \"9\", \"10\" ], titleTest: \"test\" }\n}\n```\n\nFiltering\n\n```typescript\nimport { JsonApiDeserializer } from \"...\";\n\n// allowed elements\nconst whitelist = [\"title\", \"content\"];\n\nasync function main() {\n  const deserializer = new JsonApiDeserializer();\n\n  /**\n   * when a transform returns undefined instead of a tuple, the property is skipped\n   */\n  deserializer.transformAttributeFunction = (\n    key,\n    value,\n  ) =\u003e whitelist.includes(key) ? [key, value] : undefined;\n\n  const deserialized = await deserializer.deserialize({\n    data: {\n      attributes: {\n        title: \"test\",\n        content: \"test\",\n        unknownAttribute: \"blah\",\n      },\n    },\n  });\n\n  // { id: undefined, title: \"test\", content: \"test\" }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famauryd%2Fdeno-json-api-deserializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famauryd%2Fdeno-json-api-deserializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famauryd%2Fdeno-json-api-deserializer/lists"}