{"id":26457168,"url":"https://github.com/terran-source/interpolate-json","last_synced_at":"2025-08-08T04:33:54.157Z","repository":{"id":48333868,"uuid":"231196937","full_name":"Terran-Source/interpolate-json","owner":"Terran-Source","description":"Interpolate a Javascript Object or string with json - Advanced","archived":false,"fork":false,"pushed_at":"2023-09-27T20:57:45.000Z","size":582,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T08:51:24.341Z","etag":null,"topics":["interpolation","javascript","json","json-interpolation","nodejs","string-interpolation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/interpolate-json","language":"JavaScript","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/Terran-Source.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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":"2020-01-01T09:26:12.000Z","updated_at":"2024-12-17T04:38:55.000Z","dependencies_parsed_at":"2024-06-18T21:26:43.945Z","dependency_job_id":"6ff1ec71-31fe-421b-8cab-9b59c5705438","html_url":"https://github.com/Terran-Source/interpolate-json","commit_stats":{"total_commits":159,"total_committers":1,"mean_commits":159.0,"dds":0.0,"last_synced_commit":"376232510561cf9914e2790317f7de8de370a86b"},"previous_names":[],"tags_count":64,"template":false,"template_full_name":null,"purl":"pkg:github/Terran-Source/interpolate-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terran-Source%2Finterpolate-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terran-Source%2Finterpolate-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terran-Source%2Finterpolate-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terran-Source%2Finterpolate-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Terran-Source","download_url":"https://codeload.github.com/Terran-Source/interpolate-json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Terran-Source%2Finterpolate-json/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267429568,"owners_count":24085974,"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-07-27T02:00:11.917Z","response_time":82,"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":["interpolation","javascript","json","json-interpolation","nodejs","string-interpolation"],"created_at":"2025-03-18T22:43:25.589Z","updated_at":"2025-07-27T21:40:33.465Z","avatar_url":"https://github.com/Terran-Source.png","language":"JavaScript","readme":"# interpolate-json [![NPM version](https://img.shields.io/npm/v/interpolate-json.svg?style=plastic)](https://www.npmjs.com/package/interpolate-json)\n\n![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/Terran-Source/interpolate-json/main.yml?event=push\u0026label=Github-Build\u0026style=plastic) [![node](https://img.shields.io/node/v/interpolate-json?logo=nodejs\u0026style=plastic)](https://www.npmjs.com/package/interpolate-json) [![GitHub](https://img.shields.io/github/license/Terran-Source/interpolate-json?logo=github\u0026style=plastic)](LICENSE)\n\nInterpolate a Javascript Object (json) or string with (another) **json** - Advanced (or ***Substitution***, as others may like to call it).\n\nMinimalist \u0026 lightweight ;) approach to handle interpolation, which packs way more punch than simple string *parameter* replacement.\n\nSupports:\n\n1. `${string}` interpolation\n2. `${json}` interpolation\n3. `${multi.level}` json notation\n4. single `${= JavaScript.expression() =}` evaluation\n5. custom `{{parameter_boundary}}` declaration\n\n## Install\n\n```bash\n# with npm\nnpm install interpolate-json\n\n# or with Yarn\nyarn add interpolate-json\n```\n\n## Usage\n\n#### Declaration\n\n```javascript\n// declare the varible at the beginning\nconst interpolation = require('interpolate-json').interpolation;\n// or\nconst { interpolation } = require('interpolate-json');\n```\n```typescript\n// or the import syntax\nimport { interpolation } from 'interpolate-json';\n```\n\n#### string\n\n```javascript\n// String\nlet someString = 'I want to be ${character} in ${business.type} by being a ${business.post}';\nlet values = {\n  character: 'a Hero',\n  business: {\n    type: 'saving people',\n    post: 'Doctor',\n  },\n};\nsomeString = interpolation.expand(someString, values);\nconsole.log(someString);\n// output:  I want to be a Hero in saving people by being a Doctor\n\n// or using ENVIRONMENT_VARIABLES\n// test-string.js\nlet someString = \"Hi, my name is '${USER_NAME}'. I'm ${USER_AGE}\";\nconsole.log(interpolation.expand(someString, process.env));\n// execute using: USER_NAME='John' USER_AGE=19 node test-string.js\n// output:  Hi, my name is 'John'. I'm 19\n```\n\n#### json\n\n```javascript\n// Json\nlet myJson = {\n  port: '8080',\n  server: 'www.example.com',\n  user: 'abcd',\n  password: 'P@ss#ord',\n  url: 'https://${user}:${= encodeURIComponent(${password}) =}@${server}:${port}'\n};\nconsole.log(interpolation.expand(myJson)); // Look for values inside itself\n// output:\n{\n  \"port\": \"8080\",\n  \"server\": \"www.example.com\",\n  \"user\": \"abcd\",\n  \"password\": \"P@ss#ord\",\n  \"url\": \"https://abcd:P%40ss%23ord@www.example.com:8080\"\n}\n\n// Let's sweeten the deal with ENVIRONMENT_VARIABLES\n// test-json.js\nlet myJson = {\n  port: '${PORT}',\n  server: 'www.example.com',\n  user: '${=${USER_NAME}.toLowerCase()=}',\n  password: '${USER_PASSWORD}',\n  url: 'https://${user}:${= encodeURIComponent(${password}) =}@${server}:${port}'\n};\n\nconsole.log(interpolation.expand(myJson));\n// execute using: PORT=8080 USER_NAME='John' USER_PASSWORD='P@ss#ord' node test-json.js\n// output:\n{\n  \"port\": \"8080\",\n  \"server\": \"www.example.com\",\n  \"user\": \"john\",\n  \"password\": \"P@ss#ord\",\n  \"url\": \"https://john:P%40ss%23ord@www.example.com:8080\"\n}\n\n```\n\n\u003e Notice that `${= =}` notation. It's a cool way to use JavaScript expression (not expression\u003cu\u003e_s_\u003c/u\u003e, yet, just a single line).\n\nGet the full documentation in [WIKI](https://github.com/Terran-Source/interpolate-json/blob/master/WIKI.md)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterran-source%2Finterpolate-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterran-source%2Finterpolate-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterran-source%2Finterpolate-json/lists"}