← All procedures

json.merge

Apply an RFC 7386 JSON merge patch to a JSON value

MCPCLI
Package
@procedures/json · README
Path
["json","merge"]
CLI
mark json merge --target <any> --patch <any>
MCP tool
json.merge on the dev-tools server
As data
{"$proc":["json","merge"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/json/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["json","merge"], { target: "<target>", patch: "<patch>" });
console.log(JSON.stringify(result));

From the command line

$ mark json merge --target <any> --patch <any>

As data, in a program

{
  "$proc": ["json", "merge"],
  "input": { "target": "<target>", "patch": "<patch>" }
}

Input

FieldTypeRequiredDefaultDescription
targetanyyesThe JSON value to change
patchanyyesThe merge patch (RFC 7386): an object of changes, where null removes a key

Output

FieldTypeRequiredDefaultDescription
valueanyyesThe value after the merge
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "target": {
        "description": "The JSON value to change"
      },
      "patch": {
        "description": "The merge patch (RFC 7386): an object of changes, where null removes a key"
      }
    },
    "required": [
      "target",
      "patch"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "value": {
        "description": "The value after the merge"
      }
    },
    "required": [
      "value"
    ],
    "additionalProperties": false
  }
}