Skip to main content

JSON Multi Merge

A high-performance JSON merging library powered by Rust, featuring advanced merge rules and key modifiers.

Features

  • Recursive Object Merging: Deep merge nested JSON objects
  • Array Replacement: Second object's arrays take precedence
  • Key Modifiers:
    • key! - Replace value instead of merging
    • key-- - Remove this key from the result
    • key-history - Append list value instead of replacing
  • Type Conflict Resolution: Last object's type wins
  • Null Handling: Treat null as a regular value
  • High Performance: Rust backend for efficient deep merges

Installation

pip install json-multi-merge

Usage

Variadic Input

The merge function now accepts any number of dictionary arguments:

# Single dictionary
merge({"a": 1})

# Multiple dictionaries
merge({"a": 1}, {"b": 2}, {"c": 3})

# From a list (using unpacking)
dicts = [{"a": 1}, {"b": 2}]
merge(*dicts)

# Invalid usage (will raise TypeError)
merge({"a": 1}, [1, 2, 3])  # Second item is not a dict
merge("not a list")         # Not a list at all

Basic Merge

from json_multi_merge import merge

a = {"name": "Alice", "age": 30}
b = {"age": 31, "city": "Paris"}
result = merge(a, b)
# {'name': 'Alice', 'age': 31, 'city': 'Paris'}

Nested Object Merging

base = {
    "user": {
        "name": "Alice",
        "contact": {"email": "alice@example.com"}
    }
}
update = {
    "user": {
        "contact": {"phone": "555-1234"},
        "preferences": {"theme": "dark"}
    }
}
result = merge(base, update)
# {
#   "user": {
#     "name": "Alice",
#     "contact": {"email": "alice@example.com", "phone": "555-1234"},
#     "preferences": {"theme": "dark"}
#   }
# }

Merging Multiple Objects

Merge any number of JSON objects sequentially:

result = merge(
    {"base": 1},
    {"base": 2, "new!": "value"},
    {"base--": None, "final": True}
)
# Result: {'new': 'value', 'final': True}

Batch Processing Example

configs = [
    {"defaults": {"timeout": 30}},
    {"defaults": {"retries": 3}},
    {"defaults!": {"cache": "enabled"}},
    {"defaults--": {}, "environment": "prod"}
]

final_config = merge(*configs)
# Result: {'environment': 'prod'}

Array Replacement

base = {"tags": ["old"], "items": [1, 2]}
update = {"tags": ["new"], "items!": [3, 4]}
result = merge(base, update)
# {"tags": ["new"], "items": [3, 4]}

Key Modifiers

Replace (!) and Omit (--)

config = {
    "debug": True,
    "plugins": ["basic"],
    "temp_data": {"key": "value"}
}
update = {
    "debug!": False,
    "plugins--": None,
    "temp_data--": {"key": "value"}
}
result = merge(config, update)
# {"debug": False}

Deeply Nested Modifiers

base = {
    "system": {
        "settings": {
            "logging": {"level": "info"},
            "backups": {"enabled": False}
        }
    }
}
update = {
    "system!": {
        "settings--": {"logging": {"level": "info"}},
        "new_settings": {"cache_size": "256MB"}
    }
}
result = merge(base, update)
# {
#   "system": {
#     "new_settings": {"cache_size": "256MB"}
#   }
# }

Type Conflicts

base = {"data": {"values": [1, 2, 3]}}
update = {"data": "invalid"}
result = merge(base, update)
# {"data": "invalid"}

Null Handling

base = {"user": None}
update = {"user!": {"name": "Bob"}}
result = merge(base, update)
# {"user": {"name": "Bob"}}

API Reference

merge(base: dict, update: dict) -> dict

Merges two JSON objects according to the rules:

  1. Objects are merged recursively
  2. Arrays are replaced
  3. Key modifiers change merge behavior:
    • key!: Replace value completely
    • key--: Remove key from result
  4. Last object's value type wins in conflicts

Performance

The Rust implementation provides significant performance benefits for:

  • Large JSON documents (10k+ elements)
  • Deeply nested structures (10+ levels)
  • Batch processing operations
# Benchmark example (1k nested objects)
import timeit
setup = '''
import json_multi_merge
base = {"data": {"nested": {"value": 1}}}
update = {"data": {"nested": {"value!": 2}}}
'''
print(timeit.timeit('json_multi_merge.merge(base, update)', setup, number=10000))
# Typical result: ~0.8 seconds (vs ~4.2 seconds for pure Python equivalent)

License

MIT License - See LICENSE for details.

Metadata

Release files for json-multi-merge 0.3.1

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

Source distribution (sdist)

Source distribution for json-multi-merge 0.3.1
File Size Uploaded Provenance Actions
json_multi_merge-0.3.1.tar.gz 9.8 kB Without provenance Details for json_multi_merge-0.3.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for json-multi-merge 0.3.1
File Actions
json_multi_merge-0.3.1-cp37-abi3-win_amd64.whl CPython 3.7 abi3 Windows x86-64 Details for json_multi_merge-0.3.1-cp37-abi3-win_amd64.whl
json_multi_merge-0.3.1-cp37-abi3-win32.whl CPython 3.7 abi3 Windows x86-32 Details for json_multi_merge-0.3.1-cp37-abi3-win32.whl
json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_x86_64.whl CPython 3.7 abi3 Linux musl 1.2+ x86-64 Details for json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_x86_64.whl
json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_i686.whl CPython 3.7 abi3 Linux musl 1.2+ x86-32 Details for json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_i686.whl
json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_armv7l.whl CPython 3.7 abi3 Linux musl 1.2+ ARMv7l Details for json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_armv7l.whl
json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_aarch64.whl CPython 3.7 abi3 Linux musl 1.2+ ARM64 Details for json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_aarch64.whl
json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 abi3 Linux glibc 2.17+ x86-64 Details for json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl CPython 3.7 abi3 Linux glibc 2.17+ ARMv7l Details for json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.7 abi3 Linux glibc 2.17+ ARM64 Details for json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
json_multi_merge-0.3.1-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl CPython 3.7 abi3 Linux glibc 2.5+ x86-32 Details for json_multi_merge-0.3.1-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
json_multi_merge-0.3.1-cp37-abi3-macosx_11_0_arm64.whl CPython 3.7 abi3 macOS 11.0+ ARM64 Details for json_multi_merge-0.3.1-cp37-abi3-macosx_11_0_arm64.whl
json_multi_merge-0.3.1-cp37-abi3-macosx_10_12_x86_64.whl CPython 3.7 abi3 macOS 10.12+ x86-64 Details for json_multi_merge-0.3.1-cp37-abi3-macosx_10_12_x86_64.whl

Total release size: 3.6 MB

Release files / json_multi_merge-0.3.1.tar.gz

Download URL json_multi_merge-0.3.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8ab00d004379f946bd1ea439da7c50bdf24009e3dc8c7c6bf75970fd41fd0d3e
BLAKE2b-256 checksum
How to use checksums
3c5afef4e865babf6abfc09c21b6cdfa106ec25dbf1f5dd0230f2b525b9ea8c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-win_amd64.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-win_amd64.whl
Size 122.2 kB
Tags CPython 3.7 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9d129790eec8b14b1f38093bd30a07a2e446d80c962f67c228d0575ae7b1b055
BLAKE2b-256 checksum
How to use checksums
fc7e0c2298266a4b6ce4744d4ec9fd55997df1e81cd463ef0391b43ff5547e73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-win32.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-win32.whl
Size 115.8 kB
Tags CPython 3.7 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
c9dbda2d5086acd1731f15443b9edfc4277f1138c1ef3c6f15c739c9d4a1124d
BLAKE2b-256 checksum
How to use checksums
6300b91141ccc5b146277a8444559d8f9b68e620c6360221f899f04146160e33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_x86_64.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_x86_64.whl
Size 429.0 kB
Tags CPython 3.7 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
a8df2e1b34d2fe1bc896d8efb641f98ba7f488364766e637a6020f9ab159ce55
BLAKE2b-256 checksum
How to use checksums
52af06e4735488fc33f61a7d2a644209c8399e666819454661c8105c86feaad4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_i686.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_i686.whl
Size 451.4 kB
Tags CPython 3.7 Linux musl 1.2+ x86-32 abi3
SHA-256 checksum
How to use checksums
6b0fbdc72c4049daf5e481b3eb0637d2eead2930a0b9f8c4ed90e321f3db9426
BLAKE2b-256 checksum
How to use checksums
51047f76adf959e98f559ef97265ccf85e029331dec222daee84e6f3b36da52d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_armv7l.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_armv7l.whl
Size 524.5 kB
Tags CPython 3.7 Linux musl 1.2+ ARMv7l abi3
SHA-256 checksum
How to use checksums
7a46bd79b4c0112dbd1e1535c8cd0abb9478b63b1cf0fe009e95b85f220e4417
BLAKE2b-256 checksum
How to use checksums
90a8fc7cdb9430a4c6da98c4c89a37672a0380c6a4590f82f0b8ad930421c240
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_aarch64.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-musllinux_1_2_aarch64.whl
Size 432.4 kB
Tags CPython 3.7 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
097d7eae4bcbdab2e8799f610f3d89a8c81da711794f5d6906818af8c3a64b03
BLAKE2b-256 checksum
How to use checksums
1a8ff77cc73441db9c16842d7c1b63d95c46ef4e214c330c338366dde3f6b146
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 258.5 kB
Tags CPython 3.7 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e779de1f0b3e1a4e2bb3fb1602bb0c9629dc9f728528459f26936052647d3694
BLAKE2b-256 checksum
How to use checksums
057d9466c8204899dd54a830474c87df3dbb8dd26828a53bbf37cb0358473105
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Size 262.0 kB
Tags CPython 3.7 Linux glibc 2.17+ ARMv7l abi3
SHA-256 checksum
How to use checksums
783b844e15e09f07101bdcfc506813bd73192636a9f21ef4a537ef72ea18a38a
BLAKE2b-256 checksum
How to use checksums
5a2e679ccc396788aeb3e07a054ff0d83aa7a6720e4d14b6bd79e5506f78d07c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 254.3 kB
Tags CPython 3.7 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
85d8d87e3b963a6a58f2df360ef98da84d07a18c8125e4b60986fab177896b7f
BLAKE2b-256 checksum
How to use checksums
7b716ce532b199411a39e7290307e9c85d5d8c281d9f1cad56a4a482ebcf74b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Size 271.3 kB
Tags CPython 3.7 Linux glibc 2.5+ x86-32 abi3
SHA-256 checksum
How to use checksums
3c2306a83d3a00238b5de2a471ca6ecbee7de5617924452d7c95bbaf94b48f24
BLAKE2b-256 checksum
How to use checksums
8614e171e8e50704187c64d71ba0a7cf55a645dfe984dc041246f66a3fefe6d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-macosx_11_0_arm64.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-macosx_11_0_arm64.whl
Size 224.7 kB
Tags CPython 3.7 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
207db64ab226c08cc4fd433bfb3a233476512fac2d73bb4bc09efe513a91e586
BLAKE2b-256 checksum
How to use checksums
71b2a14d0c27a7a25c0e8a3e34cb55bc568ed22b8a842765de14a579b96b952d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Release files / json_multi_merge-0.3.1-cp37-abi3-macosx_10_12_x86_64.whl

Download URL json_multi_merge-0.3.1-cp37-abi3-macosx_10_12_x86_64.whl
Size 231.0 kB
Tags CPython 3.7 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f78c5c7e2b4ab0c91ee393965cba8795239590762f3875eaa62b38c9819dbc5d
BLAKE2b-256 checksum
How to use checksums
2a4cdb26106daf340e5e78e771e5c0ba3b3844a8b0aeb7dfb73f7cee67ad7518
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.8.2

Security for json-multi-merge 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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