{"id":22876292,"url":"https://github.com/schapka/mergeon","last_synced_at":"2025-06-13T18:07:37.991Z","repository":{"id":57294837,"uuid":"114514953","full_name":"schapka/mergeon","owner":"schapka","description":"Loading extendable JSON structures","archived":false,"fork":false,"pushed_at":"2017-12-23T14:23:31.000Z","size":86,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T00:39:00.558Z","etag":null,"topics":["cli","data","extend","include","inheritance","json","merge","partials"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schapka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-17T06:31:32.000Z","updated_at":"2024-11-02T14:30:41.000Z","dependencies_parsed_at":"2022-08-30T18:22:01.230Z","dependency_job_id":null,"html_url":"https://github.com/schapka/mergeon","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schapka%2Fmergeon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schapka%2Fmergeon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schapka%2Fmergeon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schapka%2Fmergeon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schapka","download_url":"https://codeload.github.com/schapka/mergeon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252769137,"owners_count":21801373,"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":["cli","data","extend","include","inheritance","json","merge","partials"],"created_at":"2024-12-13T15:13:56.113Z","updated_at":"2025-05-06T20:50:15.116Z","avatar_url":"https://github.com/schapka.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/mergeon.svg?style=flat)](https://www.npmjs.org/package/mergeon)\n[![Build Status](https://travis-ci.org/schapka/mergeon.svg?branch=master)](https://travis-ci.org/schapka/mergeon)\n[![Build status](https://ci.appveyor.com/api/projects/status/cwrjsbht5tuicc94/branch/master?svg=true)](https://ci.appveyor.com/project/schapka/mergeon/branch/master)\n\n# Mergeon\n\n**Loading extendable JSON structures:**\n\n* Load data from different JSON files\n* Use wildcards/globs\n* Override inherited values\n* Merge data\n* Customize merging\n\n## Contents\n\n* [Installation](#installation)\n* [Examples](#examples)\n  * [Simple use case](#simple-use-case)\n  * [Target path](#target-path)\n  * [Wildcards](#wildcards)\n* [Usage](#usage)\n  * [JavaScript API](#javascript-api)\n  * [CLI](#cli)\n* [Options](#options)\n  * [entry](#entry)\n  * [context](#context)\n  * [extendKey](#extendkey)\n  * [mergeCustomizer](#mergecustomizer)\n\n## Installation\n\n**npm**\n\n```text\nnpm i -S mergeon\n```\n\n**yarn**\n\n```text\nyarn add mergeon\n```\n\n## Examples\n\n### Simple use case\n\nLoad data from different JSON file and override values:\n\n**`entry.json`**\n\n```json\n{\n  \"_extends\": \"./default-data.json\",\n  \"title\": \"New title\",\n  \"image\": {\n    \"alt\": \"New alt value\"\n  }\n}\n```\n\n**`default-data.json`**\n\n```json\n{\n  \"title\": \"Default title\",\n  \"image\": {\n    \"src\": \"path/to/default/image.jpg\",\n    \"alt\": \"Default alt value\"\n  }\n}\n```\n\n**Result**\n\n```json\n{\n  \"title\": \"New title\",\n  \"image\": {\n    \"src\": \"path/to/default/image.jpg\",\n    \"alt\": \"New alt value\"\n  }\n}\n```\n\n### Target path\n\nDefine a target path by using special syntax (`\u003cextendKey\u003e:\u003ctargetPath\u003e`):\n\n**`entry.json`**\n\n```json\n{\n  \"_extends:target.path\": \"./default-data.json\"\n}\n```\n\n**`default-data.json`**\n\n```json\n{\n  \"title\": \"Default title\"\n}\n```\n\n**Result**\n\n```json\n{\n  \"target\": {\n    \"path\": {\n      \"title\": \"Default title\"\n    }\n  }\n}\n```\n\n### Wildcards\n\nLoad multiple files by adding wildcards:\n\n**`entry.json`**\n\n```json\n{\n  \"_extends:buttons\": \"./buttons/*.json\"\n}\n```\n\n**`buttons/primary.json`**\n\n```json\n{\n  \"type\": \"primary\"\n}\n```\n\n**`buttons/secondary.json`**\n\n```json\n{\n  \"type\": \"secondary\"\n}\n```\n\n**Result**\n\n```json\n{\n  \"buttons\": {\n    \"primary\": {\n      \"type\": \"primary\"\n    },\n    \"secondary\": {\n      \"type\": \"secondary\"\n    }\n  }\n}\n```\n\n### Additional examples\n\nSee [test directory](https://github.com/schapka/mergeon/tree/master/test) for additional examples, including **wildcards**, **globstars**, **customized merging** and many more.\n\n## Usage\n\n### JavaScript API\n\n```js\nimport mergeon from 'mergeon';\n\nmergeon\n  .load({\n    entry: 'data/entry.json',\n  })\n  .then(result =\u003e {\n    const jsonString = JSON.stringify(result.data, null, 2);\n    /* ... */\n  })\n  .catch(error =\u003e {\n    /* ... */\n  });\n```\n\n### CLI\n\n```text\nmergeon data/entry.json \u003e output.json\n```\n\n## Options\n\n### `entry`\n\n| Type                     | Default     | Required |\n| ------------------------ | ----------- | -------- |\n| `string` \u0026#124; `object` | `undefined` | yes      |\n\n### `context`\n\n| Type     | Default         | Required |\n| -------- | --------------- | -------- |\n| `string` | `process.cwd()` | no       |\n\n\u003e **Note:** This option is not available to CLI\n\n### `extendKey`\n\n| Type     | Default      | Required |\n| -------- | ------------ | -------- |\n| `string` | `\"_extends\"` | no       |\n\n### `mergeCustomizer`\n\n| Type       | Default     | Required |\n| ---------- | ----------- | -------- |\n| `function` | `undefined` | no       |\n\nThis function will be passed as customizer to lodash’s [`_.mergeWith`](https://lodash.com/docs/4.17.4#mergeWith) method.\n\n\u003e **Note:** This option is not available to CLI\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschapka%2Fmergeon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschapka%2Fmergeon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschapka%2Fmergeon/lists"}