InTouch Hub · Blue Isle Software

JSON Diff

Compares two JSON documents and reports every added, removed and modified key or value, each with its path.

Provided free and as is, without warranty of any kind — including merchantability, fitness for a particular purpose, and the accuracy or completeness of any result. See the licence. You are responsible for checking what this produces before relying on it.

compareconfigdiffdriftjson

JSON Diff

Compares two JSON documents and reports every added, removed and modified key or value, each with its path. Runs locally in Python's standard library. No credential, no network.

Tool ID

json-diff

Credential Required

No.

Use case

Catch drift between two versions of the same JSON: yesterday's API response against today's, a config file before and after a deploy, an export against its baseline. A later task can branch on hasChanges or send summary as an alert.

Published Outputs

Output Description
hasChanges "true" or "false"
changeCount Total number of differences
summary One sentence, e.g. Found 4 difference(s): 2 added, 1 removed, 1 modified.
added JSON array of {path, key or index, value} present only in modified
removed JSON array of {path, key or index, value} present only in original
modified JSON array of {path, oldValue, newValue}
diff Everything above as one JSON object

Example

Input:

{
  "tool": "json-diff",
  "properties": {
    "original": "{\"name\": \"widget\", \"price\": 10, \"tags\": [\"a\", \"b\"], \"stock\": {\"nyc\": 4, \"sfo\": 2}}",
    "modified": "{\"name\": \"widget\", \"price\": 12, \"tags\": [\"a\", \"b\", \"c\"], \"stock\": {\"nyc\": 4}, \"sku\": \"W-1\"}"
  }
}

Actual captured output:

summary     Found 4 difference(s): 2 added, 1 removed, 1 modified.
hasChanges  true
changeCount 4
added       [{"path": "sku", "key": "sku", "value": "W-1"}, {"path": "tags[2]", "index": 2, "value": "c"}]
removed     [{"path": "stock.sfo", "key": "sfo", "value": 2}]
modified    [{"path": "price", "oldValue": 10, "newValue": 12}]

How it works

Objects are compared key by key and the comparison recurses into nested objects, so a change deep in the document is reported at its full path (stock.sfo). Arrays are compared position by position.

Each input may be JSON text or the path of a .json file readable by the InTouch server.

Chaining Patterns

Limitations

Source

tool.iml, json_diff.py

Publishes

The keys a later task may reference as {{taskName.key}}. Referencing anything not listed here resolves to nothing at run time.

Input Properties

Every property this tool accepts, from its own tool.iml.

Property Type Required Default Description
original string yes — The first (original) JSON document: JSON text, or the path of a .json file on the server.
modified string yes — The second (modified) JSON document: JSON text, or the path of a .json file on the server.