Skip to main content

jsondiff

Diff JSON and JSON-like structures in Python

>>> from jsondiff import diff

>>> diff({'a': 1}, {'a': 1, 'b': 2})
{<insert>: {'b': 2}}

>>> diff({'a': 1, 'b': 3}, {'a': 1, 'b': 2})
{<update>: {'b': 2}}

>>> diff({'a': 1, 'b': 3}, {'a': 1})
{<delete>: ['b']}

>>> diff(['a', 'b', 'c'], ['a', 'b', 'c', 'd'])
{<insert>: [(3, 'd')]}

>>> diff(['a', 'b', 'c'], ['a', 'c'])
{<delete>: [1]}

# Similar items get patched
>>> diff(['a', {'x': 3}, 'c'], ['a', {'x': 3, 'y': 4}, 'c'])
{<update>: [(1, {<insert>: {'y': 4}})]}

# Special handling of sets
>>> diff({'a', 'b', 'c'}, {'a', 'c', 'd'})
{<add>: set(['d']), <discard>: set(['b'])}

# Parse and dump JSON
>>> print diff('["a", "b", "c"]', '["a", "c", "d"]', parse=True, dump=True, indent=2)
{
  "$delete": [
    1
  ],
  "$insert": [
    [
      2,
      "d"
    ]
  ]
}

Metadata

Release files for jsondiff 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsondiff 0.1.0
File Size Uploaded
jsondiff-0.1.0.tar.gz 3.9 kB Details

Release files / jsondiff-0.1.0.tar.gz

Download URL jsondiff-0.1.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
eb41e373e88e783d61bcd3a765ac98407b2f12612b7a696084ab66129b9513f5
BLAKE2b-256 checksum
How to use checksums
8f8d8854dd0bd71705e5906481a4a515bc87f6b548bc3c7ed3d692defcd22619
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

2.2.1

2 release files

2.2.0

2 release files

2.1.2

2 release files

2.1.1

2 release files

2.0.0

2 release files

1.3.1

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.2.0

1 release file

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page