{"id":17472655,"url":"https://github.com/shinnn/json-to-es-module","last_synced_at":"2026-05-04T11:40:18.281Z","repository":{"id":57285367,"uuid":"62391814","full_name":"shinnn/json-to-es-module","owner":"shinnn","description":"Convert JSON to an ECMAScript module","archived":false,"fork":false,"pushed_at":"2019-06-12T23:59:10.000Z","size":95,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T07:20:33.421Z","etag":null,"topics":["convert","ecmascript","json","module","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinnn.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":"2016-07-01T12:34:59.000Z","updated_at":"2024-07-01T19:26:01.000Z","dependencies_parsed_at":"2022-09-10T09:56:20.590Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/json-to-es-module","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fjson-to-es-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fjson-to-es-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fjson-to-es-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fjson-to-es-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/json-to-es-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245991554,"owners_count":20706126,"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":["convert","ecmascript","json","module","nodejs"],"created_at":"2024-10-18T17:30:22.962Z","updated_at":"2026-05-04T11:40:18.253Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json-to-es-module\n\n[![npm version](https://img.shields.io/npm/v/json-to-es-module.svg)](https://www.npmjs.com/package/json-to-es-module)\n[![Build Status](https://travis-ci.com/shinnn/json-to-es-module.svg?branch=master)](https://travis-ci.com/shinnn/json-to-es-module)\n[![codecov](https://codecov.io/gh/shinnn/json-to-es-module/branch/master/graph/badge.svg)](https://codecov.io/gh/shinnn/json-to-es-module)\n\nConvert [JSON](https://tools.ietf.org/html/rfc8259) to an ECMAScript module\n\n```json\n{\n  \"name\": \"Sam\"\n}\n```\n\n↓\n\n```javascript\nexport default {\n  name: 'Sam'\n};\n```\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).\n\n```\nnpm install json-to-es-module\n```\n\n## API\n\n```javascript\nconst jsonToEsModule = require('json-to-es-module');\n```\n\n### jsonToEsModule(*str* [, *option*])\n\n*str*: `string` (JSON string)  \n*option*: `Object`  \nReturn: `string`\n\n```javascript\njsonToEsModule(`{\n  \"foo\": 1,\n  \"bar\": [\n    true,\n    null\n  ]\n}`);\n//=\u003e 'export default {\\n\\tfoo: 1,\\n\\tbar: [\\n\\t\\ttrue,\\n\\t\\tnull\\n\\t]\\n};\\n'\n```\n\n#### option.filename\n\nType: `string`\n\nFilename displayed in the error message.\n\n```javascript\ntry {\n  jsonToEsModule('\"');\n} catch (err) {\n  err.message; //=\u003e Unexpected end of JSON input while parsing near '\"'\n}\n\ntry {\n  jsonToEsModule('\"', {filename: 'source.json'});\n} catch (err) {\n  err.message; //=\u003e Unexpected end of JSON input while parsing near '\"' in source.json\n}\n```\n\n## License\n\n[ISC License](./LICENSE) © 2018 - 2019 Shinnosuke Watanabe\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fjson-to-es-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Fjson-to-es-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fjson-to-es-module/lists"}