{"id":18048517,"url":"https://github.com/bent10/json-loose","last_synced_at":"2025-10-13T01:23:08.717Z","repository":{"id":199957679,"uuid":"704400365","full_name":"bent10/json-loose","owner":"bent10","description":"Transforms loosely structured plain object strings into valid JSON strings.","archived":false,"fork":false,"pushed_at":"2025-09-25T17:00:40.000Z","size":183,"stargazers_count":7,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-13T01:23:06.403Z","etag":null,"topics":["json","jsonify","loose","object","plain-object","stringify"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/json-loose","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/bent10.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-10-13T07:18:13.000Z","updated_at":"2025-09-26T06:55:57.000Z","dependencies_parsed_at":"2023-11-13T02:30:56.268Z","dependency_job_id":"353677cb-85d4-41fa-ae91-2410c5c5760d","html_url":"https://github.com/bent10/json-loose","commit_stats":{"total_commits":41,"total_committers":3,"mean_commits":"13.666666666666666","dds":"0.36585365853658536","last_synced_commit":"9f9683139e93b7303db706d7daefbd2b2a457c4c"},"previous_names":["bent10/json-loose"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/bent10/json-loose","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bent10%2Fjson-loose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bent10%2Fjson-loose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bent10%2Fjson-loose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bent10%2Fjson-loose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bent10","download_url":"https://codeload.github.com/bent10/json-loose/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bent10%2Fjson-loose/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013886,"owners_count":26085325,"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-12T02:00:06.719Z","response_time":53,"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","jsonify","loose","object","plain-object","stringify"],"created_at":"2024-10-30T20:13:15.334Z","updated_at":"2025-10-13T01:23:08.691Z","avatar_url":"https://github.com/bent10.png","language":"TypeScript","readme":"# json-loose\n\nA utility that converts loosely structured data into valid JSON strings, ensuring data consistency and compatibility. It provides a safer alternative to using the `Function` constructor to create objects from strings.\n\n## Install\n\nYou can install this module using npm or yarn, it's only `2.93 kB │ gzip: 1.32 kB`:\n\n```bash\nnpm i json-loose\n# or\nyarn add json-loose\n```\n\nAlternatively, you can also include this module directly in your HTML file from [CDN](https://www.jsdelivr.com/package/npm/json-loose?tab=files\u0026path=dist):\n\n| Type | URL                                                         |\n| :--- | :---------------------------------------------------------- |\n| ESM  | `https://cdn.jsdelivr.net/npm/json-loose/+esm`              |\n| CJS  | `https://cdn.jsdelivr.net/npm/json-loose/dist/index.cjs`    |\n| UMD  | `https://cdn.jsdelivr.net/npm/json-loose/dist/index.umd.js` |\n\n## Usage\n\nThe `jsonLoose` function takes an invalid JSON string as input and returns a JSON-like string representation of the transformed data.\n\n```js\nimport jsonLoose from 'json-loose'\n\nconst invalidJSON = `\n{\n  name: 'Bambang Ekalaya',\n  username: \"@palgunadi\",\n  age: 30,\n  isStudent: true\n}\n`\nconst data = jsonLoose(invalidJSON)\n// now you can `JSON.parse(data)`\n\nconsole.log(data)\n```\n\nYields:\n\n```json\n{\n  \"name\": \"Bambang Ekalaya\",\n  \"username\": \"@palgunadi\",\n  \"age\": 30,\n  \"isStudent\": true\n}\n```\n\nYou can also specify an optional context object to transform Identifier values:\n\n```js\nimport jsonLoose from 'json-loose'\n\nconst invalidJSON = `\n[\n  \"foo\",\n  true,\n  [1, 2, wife],\n  {\n    [n]: 'Bambang Ekalaya',\n    username: \"@palgunadi\",\n    age: 30,\n    address: [{city:city}, [country]],\n    skills: skills,\n    isStudent: true,\n    relation: {\n      wife: wife,\n      guru: guru,\n      [bar]: \"qux\"\n    },\n  },\n],\n`\n\nconst context = {\n  n: 'name',\n  skills: 'Archery',\n  city: 'Nishada',\n  country: 'Aravalli',\n  wife: 'Anggraini',\n  guru: 'Drona'\n}\n\nconst data = jsonLoose(invalidJSON, context)\n// now you can `JSON.parse(data)`\n\nconsole.log(data)\n```\n\nYields:\n\n```json\n[\n  \"foo\",\n  true,\n  [1, 2, \"Anggraini\"],\n  {\n    \"name\": \"Bambang Ekalaya\",\n    \"username\": \"@palgunadi\",\n    \"age\": 30,\n    \"address\": [{ \"city\": \"Nishada\" }, [\"Aravalli\"]],\n    \"skills\": \"Archery\",\n    \"isStudent\": true,\n    \"relation\": { \"wife\": \"Anggraini\", \"guru\": \"Drona\", \"bar\": \"qux\" }\n  }\n]\n```\n\n## Related\n\n- [attributes-parser](https://github.com/bent10/attributes-parser) – A utility for parsing and tokenizing attributes string into meaningful tokens and key-value pairs.\n\n## Contributing\n\nWe 💛\u0026nbsp; issues.\n\nWhen committing, please conform to [the semantic-release commit standards](https://www.conventionalcommits.org/). Please install `commitizen` and the adapter globally, if you have not already.\n\n```bash\nnpm i -g commitizen cz-conventional-changelog\n```\n\nNow you can use `git cz` or just `cz` instead of `git commit` when committing. You can also use `git-cz`, which is an alias for `cz`.\n\n```bash\ngit add . \u0026\u0026 git cz\n```\n\n## License\n\n![GitHub](https://img.shields.io/github/license/bent10/json-loose)\n\nA project by [Stilearning](https://stilearning.com) \u0026copy; 2023.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbent10%2Fjson-loose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbent10%2Fjson-loose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbent10%2Fjson-loose/lists"}