{"id":31791039,"url":"https://github.com/vinsjo/safe-json-decode","last_synced_at":"2025-10-10T16:50:33.431Z","repository":{"id":65561189,"uuid":"526600032","full_name":"vinsjo/safe-json-decode","owner":"vinsjo","description":"A minimal package for encoding and decoding JSON-data without thrown errors","archived":false,"fork":false,"pushed_at":"2025-07-14T09:52:06.000Z","size":641,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-21T23:03:58.503Z","etag":null,"topics":["json"],"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/vinsjo.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":"2022-08-19T12:33:27.000Z","updated_at":"2025-07-14T09:53:19.000Z","dependencies_parsed_at":"2023-01-29T16:35:12.186Z","dependency_job_id":null,"html_url":"https://github.com/vinsjo/safe-json-decode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vinsjo/safe-json-decode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinsjo%2Fsafe-json-decode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinsjo%2Fsafe-json-decode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinsjo%2Fsafe-json-decode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinsjo%2Fsafe-json-decode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vinsjo","download_url":"https://codeload.github.com/vinsjo/safe-json-decode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vinsjo%2Fsafe-json-decode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004687,"owners_count":26083751,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["json"],"created_at":"2025-10-10T16:50:31.929Z","updated_at":"2025-10-10T16:50:33.425Z","avatar_url":"https://github.com/vinsjo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# safe-json-decode\n\n`safe-json-decode` is a minimal package for encoding and decoding json without unhandled exceptions being thrown on failure\n\nPackage is bundled using [unbuild](https://www.npmjs.com/package/unbuild)\n\n## Installation\n\n`npm i safe-json-decode`\n\n### In Node.js\n\n```js\n// ESM:\nimport { safeJsonDecode, safeJsonEncode } from 'safe-json-decode';\n// CommonJS:\nconst { safeJsonDecode, safeJsonEncode } = require('safe-json-decode');\n```\n\n## Usage\n\n```js\n// Same behavior as JSON.parse with valid JSON\nsafeJsonDecode('{ \"foo\": \"bar\" }'); // =\u003e {foo: 'bar'}\n// Returns null if JSON.parse fails\nsafeJsonDecode('{ invalid }'); // =\u003e null\n\n\n// Same behavior as JSON.stringify with value that can be serialized\nsafeJsonEncode({ foo: 'bar' }); // =\u003e '{\"foo\": \"bar\"}'\n// Returns null if JSON.stringify fails\nconst objectWithCircularReference = {};\nobjectWithCircularReference.self = objectWithCircularReference;\nsafeJsonEncode(objectWithCircularReference);\n\n\n// Handle side effects if error is caught\n\nconst handleError = (error) =\u003e console.error(error);\n\nsafeJsonDecode('{ invalid }', undefined, handleError); \nsafeJsonEncode(objectWithCircularReference, undefined, undefined, handleError);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinsjo%2Fsafe-json-decode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvinsjo%2Fsafe-json-decode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvinsjo%2Fsafe-json-decode/lists"}