JSON merge patch
json-merge-patch · version 1.0.0 · JSON & JSONL · free, no key needed
Apply an RFC 7396 JSON Merge Patch to a JSON value.
Use when you need to: json merge patch · apply json merge patch · rfc 7396 merge patch.
Supported
- json merge patch
- apply json merge patch
- rfc 7396 merge patch
Not supported
- json patch rfc 6902
- elementwise array merge
- json pointer set
- fuzzy merge
- read files
- fetch urls
Behavior
- If patch is not a JSON object, including when it is an array or null, the result is the patch.
- If patch is an object and target is not a non-array object, merging starts from an empty object.
- A null patch value deletes that own key; deleting a missing key is a no-op.
- Nested objects are merged recursively in Object.keys order; arrays and other non-objects replace.
- Result objects are null-prototype copies. Inputs are not mutated.
- Prototype-like names are ordinary own keys.
- JSON numbers must be safe integers. Depth is at most 16 and at most 5000 own keys are visited per value.
Input
target(any, required)patch(any, required)
Output
value(any, required)
Limits
- max depth: 16
- max own keys visited: 5000
- max output bytes: 1048576
Example
Request input:
{
"target": {
"title": "Goodbye!",
"author": {
"givenName": "John",
"familyName": "Doe"
},
"tags": [
"example",
"sample"
],
"content": "This will be unchanged"
},
"patch": {
"title": "Hello!",
"phoneNumber": "+01-123-456-7890",
"author": {
"familyName": null
},
"tags": [
"example"
]
}
}
Response:
{
"result": {
"value": {
"title": "Hello!",
"author": {
"givenName": "John"
},
"tags": [
"example"
],
"content": "This will be unchanged",
"phoneNumber": "+01-123-456-7890"
}
}
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "json-merge-patch",
"version": "1.0.0",
"input": {
"target": {
"title": "Goodbye!",
"author": {
"givenName": "John",
"familyName": "Doe"
},
"tags": [
"example",
"sample"
],
"content": "This will be unchanged"
},
"patch": {
"title": "Hello!",
"phoneNumber": "+01-123-456-7890",
"author": {
"familyName": null
},
"tags": [
"example"
]
}
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/json-merge-patch/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"target":{"title":"Goodbye!","author":{"givenName":"John","familyName":"Doe"},"tags":["example","sample"],"content":"This will be unchanged"},"patch":{"title":"Hello!","phoneNumber":"+01-123-456-7890","author":{"familyName":null},"tags":["example"]}}'
The machine-readable contract is at /v1/tools/json-merge-patch/versions/1.0.0.
CLI
node cli.mjs run json-merge-patch 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- Array to JSONL: Serialize an array of JSON-safe values as JSON Lines text.
- JSON array anti join: Anti join two JSON arrays of objects on exact keys.
- JSON array concat: Concatenate multiple JSON arrays of objects into one.
- JSON array count: Count structural occurrences in a JSON array in first-seen order.
- JSON array distinct by: Deduplicate a JSON array of objects based on specific keys.
- JSON array drop keys: Remove specific keys from each object in a JSON array.