← All procedures

json.diff

Give the RFC 6902 JSON Patch that changes one JSON value into another

MCPCLI
Package
@procedures/json · README
Path
["json","diff"]
CLI
mark json diff --from <any> --to <any>
MCP tool
json.diff on the dev-tools server
As data
{"$proc":["json","diff"],"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","diff"], { from: "<from>", to: "<to>" });
console.log(JSON.stringify(result));

From the command line

$ mark json diff --from <any> --to <any>

As data, in a program

{
  "$proc": ["json", "diff"],
  "input": { "from": "<from>", "to": "<to>" }
}

Input

FieldTypeRequiredDefaultDescription
fromanyyesThe first JSON value
toanyyesThe second JSON value

Output

FieldTypeRequiredDefaultDescription
patchobject[]yesThe JSON Patch (RFC 6902) that changes from into to
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "from": {
        "description": "The first JSON value"
      },
      "to": {
        "description": "The second JSON value"
      }
    },
    "required": [
      "from",
      "to"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "patch": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "op": {
              "type": "string",
              "enum": [
                "add",
                "remove",
                "replace",
                "move",
                "copy",
                "test"
              ],
              "description": "The operation"
            },
            "path": {
              "type": "string",
              "description": "The JSON Pointer of the location"
            },
            "from": {
              "description": "The JSON Pointer of the source of move and copy",
              "type": "string"
            },
            "value": {
              "description": "The value of add, replace and test"
            }
          },
          "required": [
            "op",
            "path"
          ],
          "additionalProperties": false
        },
        "description": "The JSON Patch (RFC 6902) that changes from into to"
      }
    },
    "required": [
      "patch"
    ],
    "additionalProperties": false
  }
}