{"id":34328279,"url":"https://github.com/ryanmarcus/dirty-json","last_synced_at":"2026-04-06T07:01:36.616Z","repository":{"id":21482278,"uuid":"24801041","full_name":"RyanMarcus/dirty-json","owner":"RyanMarcus","description":"A parser for invalid JSON","archived":false,"fork":false,"pushed_at":"2024-06-01T15:08:04.000Z","size":277,"stargazers_count":334,"open_issues_count":14,"forks_count":30,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-12-21T02:43:40.267Z","etag":null,"topics":["javascript","json","parse","resiliency"],"latest_commit_sha":null,"homepage":null,"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/RyanMarcus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-10-04T20:42:22.000Z","updated_at":"2025-12-11T10:06:38.000Z","dependencies_parsed_at":"2024-06-18T13:45:39.801Z","dependency_job_id":"1385ddef-b573-4fa1-b0b7-c4dd77b9e13c","html_url":"https://github.com/RyanMarcus/dirty-json","commit_stats":{"total_commits":149,"total_committers":5,"mean_commits":29.8,"dds":"0.18120805369127513","last_synced_commit":"215fa3254f12fa279c5affcd7180d39de182faee"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RyanMarcus/dirty-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanMarcus%2Fdirty-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanMarcus%2Fdirty-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanMarcus%2Fdirty-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanMarcus%2Fdirty-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RyanMarcus","download_url":"https://codeload.github.com/RyanMarcus/dirty-json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RyanMarcus%2Fdirty-json/sbom","scorecard":{"id":123494,"data":{"date":"2025-08-11","repo":{"name":"github.com/RyanMarcus/dirty-json","commit":"d5c0a392ce9a3665937ef436e06fd2cf35a8ce4d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":1,"reason":"Found 3/26 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU Affero General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 7 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T03:06:26.777Z","repository_id":21482278,"created_at":"2025-08-16T03:06:26.778Z","updated_at":"2025-08-16T03:06:26.778Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31463015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"online","status_checked_at":"2026-04-06T02:00:07.287Z","response_time":112,"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":["javascript","json","parse","resiliency"],"created_at":"2025-12-17T17:05:56.170Z","updated_at":"2026-04-06T07:01:36.610Z","avatar_url":"https://github.com/RyanMarcus.png","language":"JavaScript","readme":"# dirty-json\n\n[ ![Codeship Status for RyanMarcus/dirty-json](https://codeship.com/projects/cbc19870-2e42-0132-d30c-4adef3b19db7/status)](https://www.codeship.io/projects/39346)  [![Coverage Status](https://coveralls.io/repos/github/RyanMarcus/dirty-json/badge.svg?branch=master)](https://coveralls.io/github/RyanMarcus/dirty-json?branch=master) ![NPM version](https://badge.fury.io/js/dirty-json.svg)\n\n\n[ ![AGPL](http://www.gnu.org/graphics/agplv3-155x51.png) ](http://www.gnu.org/licenses/agpl-3.0.en.html)\n\n\n```\nnpm install dirty-json\n```\n\n\nA JSON parser that tries to handle non-conforming or otherwise invalid JSON.\n\nYou can play around with a demo here: [http://rmarcus.info/dirty-json/](http://rmarcus.info/dirty-json)\n\nYou might also be interested in [my blog post about the parser](http://rmarcus.info/blog/2014/10/05/dirty-json-parser.html).\n\nTurn this:\n\n    [5, .5, 'single quotes', \"quotes in \"quotes\" in quotes\"]\n\nInto this:\n\n    [5,0.5,\"single quotes\",\"quotes in \\\"quotes\\\" in quotes\"]\n\n## Why?\nWe all love JSON. But sometimes, out in that scary place called \"the real world\", we see something like this:\n\n    { \"user\": \"\u003cdiv class=\"user\"\u003eRyan\u003c/div\u003e\" }\n\nOr even something like this:\n\n    { user: '\u003cdiv class=\"user\"\u003e\n\tRyan\n\t\u003c/div\u003e' }\n\nWhile these are obviously cringe-worthy, we still want a way to parse them. `dirty-json` provides a library to do exactly that.\n\n## Examples\n`dirty-json` does not require object keys to be quoted, and can handle single-quoted value strings.\n\n```javascript\nconst dJSON = require('dirty-json');\nconst r = dJSON.parse(\"{ test: 'this is a test'}\")\nconsole.log(JSON.stringify(r));\n\n// output: {\"test\":\"this is a test\"}\n```\n\n`dirty-json` can handle embedded quotes in strings.\n\n```javascript\nconst dJSON = require('dirty-json');\nconst r = dJSON.parse('{ \"test\": \"some text \"a quote\" more text\"}');\nconsole.log(JSON.stringify(r));\n\n// output: {\"test\":\"some text \\\"aquote\\\" more text\"}\n```\n\n`dirty-json` can handle newlines inside of a string.\n\n```javascript\nconst dJSON = require('dirty-json');\nconst r = dJSON.parse('{ \"test\": \"each \\n on \\n new \\n line\"}');\nconsole.log(JSON.stringify(r));\n\n// output: {\"test\":\"each \\n on \\n new \\n line\"}\n```\n\nOptionally, `dirty-json` can handle duplicate keys differently from standard JSON.\n\n```javascript\nconst dJSON = require('dirty-json');\nconst r = dJSON.parse('{\"key\": 1, \"key\": 2, \\'key\\': [1, 2, 3]}');\nconsole.log(JSON.stringify(r));\n// output: {\"key\": [1, 2, 3]}\n\nconst r = dJSON.parse('{\"key\": 1, \"key\": 2, \\'key\\': [1, 2, 3]}', {\"duplicateKeys\": true});\nconsole.log(JSON.stringify(r));\n// output: { key: { value: { value: 1, next: 2 }, next: [ 1, 2, 3 ] } }\n```\n\n## But what about THIS ambiguous example?\nSince `dirty-json` is handling malformed JSON, it will not always produce the result that you \"think\" it should. That's why you should only use this when you absolutely need it. Malformed JSON is malformed for a reason.\n\n## How does it work?\nCurrently `dirty-json` uses a lexer [powered by lex](https://github.com/aaditmshah/lexer) and a hand-written `LR(1)` parser. It shouldn't be used in any environment that requires reliable or fast results.\n\n## Security concerns\n\nThis package makes heavy use of regular expressions in its lexer. As a result, it may be vulnerable to a [REDOS attack](https://snyk.io/blog/redos-and-catastrophic-backtracking). Versions prior to `0.5.1` and after `0.0.5` were *definitely* vulnerable (thanks to [Jamie Davis](http://people.cs.vt.edu/~davisjam/) for pointing this out). I believe version `0.5.1` and later are safe, but since I do not know of any tool to verify a RegEx, I can't prove it. \n\n## Acknowledgements\nThanks to user [Moai-](https://github.com/Moai-) and [0x0a0d](https://github.com/0x0a0d)for fixing array prototype leakage.\n\n## License\n\u003e Copyright 2020, 2018, 2016, 2015, 2014 Ryan Marcus\n\u003e dirty-json is free software: you can redistribute it and/or modify\n\u003e it under the terms of the GNU Affero General Public License as published by\n\u003e the Free Software Foundation, either version 3 of the License, or\n\u003e (at your option) any later version.\n\u003e \n\u003e dirty-json is distributed in the hope that it will be useful,\n\u003e but WITHOUT ANY WARRANTY; without even the implied warranty of\n\u003e MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n\u003e GNU Affero General Public License for more details.\n\u003e \n\u003e You should have received a copy of the GNU Affero General Public License\n\u003e along with dirty-json.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanmarcus%2Fdirty-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanmarcus%2Fdirty-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanmarcus%2Fdirty-json/lists"}