{"id":24017411,"url":"https://github.com/vincentmorneau/json-mapping","last_synced_at":"2026-03-10T14:01:58.354Z","repository":{"id":19530207,"uuid":"87260219","full_name":"vincentmorneau/json-mapping","owner":"vincentmorneau","description":"Change the structure of an existing JSON object with this mapping module","archived":false,"fork":false,"pushed_at":"2023-01-06T01:32:04.000Z","size":1014,"stargazers_count":13,"open_issues_count":11,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T15:04:31.229Z","etag":null,"topics":["json","key","mapping","property","value"],"latest_commit_sha":null,"homepage":"","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/vincentmorneau.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}},"created_at":"2017-04-05T03:08:20.000Z","updated_at":"2023-08-08T11:33:04.000Z","dependencies_parsed_at":"2023-01-13T20:26:00.444Z","dependency_job_id":null,"html_url":"https://github.com/vincentmorneau/json-mapping","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentmorneau%2Fjson-mapping","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentmorneau%2Fjson-mapping/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentmorneau%2Fjson-mapping/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vincentmorneau%2Fjson-mapping/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vincentmorneau","download_url":"https://codeload.github.com/vincentmorneau/json-mapping/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249094931,"owners_count":21211837,"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":["json","key","mapping","property","value"],"created_at":"2025-01-08T09:17:41.960Z","updated_at":"2026-03-10T14:01:53.309Z","avatar_url":"https://github.com/vincentmorneau.png","language":"JavaScript","readme":"# JSON Mapping\n\n[![npm](https://img.shields.io/npm/v/json-mapping.svg)]() [![Build Status](https://travis-ci.org/vincentmorneau/json-mapping.svg?branch=master)](https://travis-ci.org/vincentmorneau/json-mapping) [![Dependency Status](https://david-dm.org/vincentmorneau/json-mapping.svg)](https://david-dm.org/vincentmorneau/json-mapping) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n\nTransform a JSON object structure.\n\n## Install\n```\nnpm install json-mapping\n```\n\n## Usage\n```javascript\nconst mapping = require('json-mapping');\n\nlet json = {\n\t\"appURL\": \"localhost\",\n\t\"object1\": {\n\t\t\"bool\": true,\n\t\t\"name\": \"app\"\n\t}\n};\n\njson = mapping.map(json, [\n\t{\n\t    oldKey: \"appURL\",\n\t    newKey: \"url\"\n\t},\n\t{\n\t    oldKey: \"object1.bool\",\n\t    newKey: \"object1.enabled\"\n\t}\n]);\n/*\n{\n\t\"url\": \"localhost\",\n\t\"object1\": {\n\t\t\"enabled\": true,\n\t\t\"name\": \"app\"\n\t}\n}\n*/\n```\n\n## Arguments\nName | Type | Description\n--- | --- | ---\njson | object | The initial JSON object to be mapped\nmapping* | array | An array containing the mapping options\n\n###### \\*mapping\nName | Type | Description\n--- | --- | ---\noldKey | string | The old property name to be mapped\nnewKey | string | The new property name to be mapped\nvalues** | array | An array of mapped values for this property mapping\ndependsOn** | object | Determines the value for the newKey based on a condition\n\n###### \\*\\*values\nName | Type | Description\n--- | --- | ---\noldValue | any | The old value of the property to be mapped\nnewValue | any | The new value of the property to be mapped\n\n###### \\*\\*dependsOn\nName | Type | Description\n--- | --- | ---\nkey | string | The key to look for\nif | any | The value to evaluate for the key\nifValue | any | When key === if, this will be the value of the newKey\nelseValue | any | When key !== if, this will be the value of the newKey\n\n## Methods\nName | Type | Return | Description\n--- | --- | --- | ---\nmap | function | object | Maps a JSON object using mapping options\n\n## Changelog\n[See changelog.](changelog.md)\n\n## License\nMIT © [Vincent Morneau](http://vmorneau.me)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincentmorneau%2Fjson-mapping","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvincentmorneau%2Fjson-mapping","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvincentmorneau%2Fjson-mapping/lists"}