{"id":41636959,"url":"https://github.com/savvasdalkitsis/json-merge","last_synced_at":"2026-01-24T14:59:15.088Z","repository":{"id":50248673,"uuid":"121030151","full_name":"savvasdalkitsis/json-merge","owner":"savvasdalkitsis","description":"json-merge is a library allowing you to merge two json files for the JVM written in Kotlin","archived":false,"fork":false,"pushed_at":"2022-08-16T17:08:03.000Z","size":74,"stargazers_count":19,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-01T22:22:09.426Z","etag":null,"topics":["json","json-merger"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/savvasdalkitsis.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":"2018-02-10T16:02:46.000Z","updated_at":"2024-08-15T18:44:44.000Z","dependencies_parsed_at":"2022-08-25T18:51:56.885Z","dependency_job_id":null,"html_url":"https://github.com/savvasdalkitsis/json-merge","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/savvasdalkitsis/json-merge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savvasdalkitsis%2Fjson-merge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savvasdalkitsis%2Fjson-merge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savvasdalkitsis%2Fjson-merge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savvasdalkitsis%2Fjson-merge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/savvasdalkitsis","download_url":"https://codeload.github.com/savvasdalkitsis/json-merge/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/savvasdalkitsis%2Fjson-merge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28730304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","json-merger"],"created_at":"2026-01-24T14:59:14.473Z","updated_at":"2026-01-24T14:59:15.081Z","avatar_url":"https://github.com/savvasdalkitsis.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/savvasdalkitsis/json-merge.svg?style=shield)](https://circleci.com/gh/savvasdalkitsis/json-merge)\n\njson-merge\n======\n\n**json-merge** is a library allowing you to merge two json files for the JVM written in Kotlin.\n\nIt currently supports two modes for merging arrays and objects.\n\n\n### Merging primitive values\n\n**json-merge** will merge all keys inside Json objects (in the default mode)\nand for keys that are present in both the base and override json, it will \nsimply use the ones from the override:\n\n- base\n\n```json\n{\n  \"age\": 24,\n  \"name\": \"John\",\n  \"registered\": false\n}\n```\n\n- override\n\n```json\n{\n  \"lastName\": \"Doe\",\n  \"age\": 30,\n  \"registered\": true\n}\n```\n\n- merged\n\n```json\n{\n  \"age\": 30,\n  \"name\": \"John\",\n  \"lastName\": \"Doe\",\n  \"registered\": true\n}\n```\n\n### Merging arrays\n\nThere are two modes for merging arrays:\n\n##### REPLACE_ARRAY\n\n```kotlin\nJsonMerger(arrayMergeMode = JsonMerger.ArrayMergeMode.REPLACE_ARRAY)\n```\n\n- base\n\n```json\n{\n  \"array\": [1, 2, 3]\n}\n```\n\n- override\n\n```json\n{\n  \"array\": [4, 5, 6]\n}\n```\n\n- merged\n\n```json\n{\n  \"array\": [4, 5, 6]\n}\n```\n\n##### MERGE_ARRAY\n\n```kotlin\nJsonMerger(arrayMergeMode = JsonMerger.ArrayMergeMode.MERGE_ARRAY)\n```\n\n- base\n\n```json\n{\n  \"array\": [1, 2, 3]\n}\n```\n- override\n\n```json\n{\n  \"array\": [4, 5, 6]\n}\n```\n\n- merged\n\n```json\n{\n  \"array\": [1, 2, 3, 4, 5, 6]\n}\n```\n\n### Merging objects\n\nThere are two modes for merging objects:\n\n##### REPLACE_OBJECT\n\n```kotlin\nJsonMerger(objectMergeMode = JsonMerger.ObjectMergeMode.REPLACE_OBJECT)\n```\n\n- base\n\n```json\n{\n  \"object\": {\n    \"param1\": true\n  }\n}\n```\n\n- override\n\n```json\n{\n  \"object\": {\n    \"param2\": true\n  }\n}\n```\n\n- merged\n\n```json\n{\n  \"object\": {\n    \"param2\": true\n  }\n}\n```\n\n##### MERGE_OBJECT\n\n```kotlin\nJsonMerger(objectMergeMode = JsonMerger.ObjectMergeMode.MERGE_OBJECT)\n```\n\n- base\n\n```json\n{\n  \"object\": {\n    \"param1\": true\n  }\n}\n```\n\n- override\n\n```json\n{\n  \"object\": {\n    \"param2\": true\n  }\n}\n```\n\n- merged\n\n```json\n{\n  \"object\": {\n      \"param1\": true,\n      \"param2\": true\n  }\n}\n```\n\n### Overriding global object merge mode\n\nIt is possible to change the object merge mode for specific json objects in the document by\nusing a special annotation key `__json-merge:objectMergeMode` with two possible values\n`replaceObject` and `mergeObject`:\n\n\n```kotlin\nJsonMerger(objectMergeMode = JsonMerger.ObjectMergeMode.MERGE_OBJECT)\n```\n\n- base\n\n```json\n{\n  \"object1\": {\n    \"param1\": true\n  },\n  \"object2\": {\n    \"param2\": true\n  }\n}\n```\n\n- override\n\n```json\n{\n  \"object1\": {\n    \"param2\": true\n  },\n  \"object2\": {\n    \"__json-merge:objectMergeMode\": \"replaceObject\",\n    \"param3\": true\n  }\n}\n```\n\n- merged\n\n```json\n{\n  \"object1\": {\n      \"param1\": true,\n      \"param2\": true\n  },\n  \"object2\": {\n      \"param3\": true // the object was replaced even though the global setting is set to merge\n  }\n}\n```\n\n\n### Things to keep in mind\n\nThe library is doing an in memory merge using recursion. So there are two things \nto keep in mind when using it. \n\n* The objects used should cannot be too large as they are expected to fit in memory \nat the same time\n* The objects should not be too nested since the operations are recursive and you'd\nbe running the risk of a stack overflow\n\n\nDownload\n======\n\nThe library is available on **Maven Central**. Note that it is still in early development\nand things might change with subsequent versions.\n\nTo use it in your project, add the following to your project\n\n- Gradle:\n\n```groovy\nimplementation 'com.savvasdalkitsis:json-merge:0.0.6'\n```\n\n- Maven:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.savvasdalkitsis\u003c/groupId\u003e\n  \u003cartifactId\u003ejson-merge\u003c/artifactId\u003e\n  \u003cversion\u003e0.0.6\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nLicense\n-------\n\n    Copyright 2018 Savvas Dalkitsis\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavvasdalkitsis%2Fjson-merge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsavvasdalkitsis%2Fjson-merge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsavvasdalkitsis%2Fjson-merge/lists"}