Skip to main content

Marshall/unmarshall JSON to/from DynamoDB JSON format — fast Python library backed by Rust

Project description

dynojson

CI PyPI crates.io Python License: MIT

Marshall / unmarshall JSON to and from DynamoDB JSON format — a fast Python library backed by Rust.

Convert between regular JSON and DynamoDB JSON format on the terminal or in your Python code. Powered by a Rust core via PyO3 for maximum performance.

  • 🔥 Works on all platforms (Linux, macOS, Windows)
  • 📄 Convert a file from a given file path
  • ✏️ Convert a JSON string directly
  • ⛓ Read from stdin — pipe in JSON from another command
  • 🍰 Extract and convert only a subset of the JSON
  • 🤝 Output can be piped or redirected to other commands
  • 🧰 Integrate into your workflow with AWS DynamoDB CLI

Installation

pip install dynojson

Python API

from dynojson import marshall, unmarshall, get_property

# Regular JSON → DynamoDB JSON
result = marshall('{"name": "Alice", "age": 30}')
# '{"name":{"S":"Alice"},"age":{"N":"30"}}'

# DynamoDB JSON → Regular JSON
result = unmarshall('{"name":{"S":"Alice"},"age":{"N":"30"}}')
# '{"name":"Alice","age":30}'

# Extract a property before converting
subset = get_property('{"Items":[{"type":{"S":"fruit"}}]}', "Items")
result = unmarshall(subset)
# '[{"type":"fruit"}]'

CLI Usage

dynojson <command> [options] <json>

Commands:
  dynojson unmarshall, u    Convert DynamoDB JSON to regular JSON
  dynojson marshall, m      Convert regular JSON to DynamoDB JSON

Options:
  -g <path>                 Extract a property before converting (dot-separated, supports *)
  --version                 Show version
  --help                    Show help

Unmarshall (DynamoDB JSON → regular JSON)

# From a JSON string
$ dynojson u '{"name":{"S":"Alice"},"age":{"N":"30"}}'
{"name":"Alice","age":30}

# From a file
$ dynojson u data.json

# From stdin
$ cat data.json | dynojson u -

# From AWS CLI
$ aws dynamodb get-item --table-name users --key '{"id":{"S":"1"}}' | dynojson u -g "Item" -

Marshall (regular JSON → DynamoDB JSON)

# From a JSON string
$ dynojson m '{"name":"Alice","age":30}'
{"name":{"S":"Alice"},"age":{"N":"30"}}

# From a file
$ dynojson m data.json

# From stdin
$ echo '{"name":"Alice"}' | dynojson m -

Extract a subset of JSON with -g

Use dot-notation to select a property. Supports numeric array indices and * to expand all array items.

# Get a specific property
$ dynojson m -g "fruits.0.benefits" food.json

# Expand all items
$ dynojson m -g "fruits.*.name" food.json

# With AWS CLI scan output
$ aws dynamodb scan --table-name food | dynojson u -g "Items" -

DynamoDB type mapping

JSON type DynamoDB descriptor
String {"S": "…"}
Number {"N": "…"}
Boolean {"BOOL": …}
Null {"NULL": true}
Array {"L": […]}
Object {"M": {…}}

String sets (SS), number sets (NS), and binary types (B, BS) are also supported during unmarshalling.

Development

Prerequisites

Setup

# Clone the repo
git clone https://github.com/cykruss/dynojson.git
cd dynojson

# Create a virtual environment
uv venv
source .venv/bin/activate

# Install build and test dependencies
uv pip install maturin pytest

# Build and install in development mode
maturin develop

# Run Rust tests
cargo test --lib

# Run Python tests
pytest tests/ -v

Project structure

dynojson/
├── Cargo.toml              # Rust package manifest
├── pyproject.toml           # Python package manifest (maturin build)
├── README.md
├── LICENSE
├── CONTRIBUTING.md
├── src/
│   ├── lib.rs               # PyO3 module + re-exports
│   ├── error.rs             # Custom error types (thiserror)
│   ├── marshall.rs          # Regular JSON → DynamoDB JSON
│   ├── unmarshall.rs        # DynamoDB JSON → regular JSON
│   └── property.rs          # Dot-path property extraction
├── python/
│   └── dynojson/
│       ├── __init__.py      # Public Python API
│       ├── _dynojson.pyi    # Type stubs
│       └── cli.py           # CLI entry point
└── tests/
    ├── test_marshall.py
    ├── test_unmarshall.py
    ├── test_property.py
    └── test_cli.py

Acknowledgements

This project was inspired by ddbjson by Alexandre Duarte, an excellent Node.js CLI tool for converting DynamoDB JSON. dynojson is a ground-up Rust rewrite with Python bindings, building on the same ideas.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dynojson-0.1.1.tar.gz (24.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dynojson-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (286.0 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

dynojson-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (273.4 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

dynojson-0.1.1-cp310-abi3-win_amd64.whl (190.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

dynojson-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (286.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

dynojson-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (273.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

dynojson-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (247.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file dynojson-0.1.1.tar.gz.

File metadata

  • Download URL: dynojson-0.1.1.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dynojson-0.1.1.tar.gz
Algorithm Hash digest
SHA256 bdb09d5033222203a9d40157eaf43669e6583f94ca01ac51d9ed9dced1b9349f
MD5 c056ccc1f50aa9b7edd4eacb6467115e
BLAKE2b-256 a951ac494c711db85fba2e5f4e858112e50c1c1e3615a7fe5c89cdbf1785e7b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynojson-0.1.1.tar.gz:

Publisher: CI.yml on cykruss/dynojson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dynojson-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dynojson-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed31ade07d178bba8306e033c3d18aa9d3406ad65ae43559ad8bd04e080db645
MD5 8bfb276774cc687605a4ad8c24000323
BLAKE2b-256 1d8714e7e1b5199811c869d7e4fc340bfe9242c85e881661e4c617c8c9669b31

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynojson-0.1.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: CI.yml on cykruss/dynojson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dynojson-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for dynojson-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 383a8d9fd93c5aa8887bc50c307ed3fe393e2c3e087acb8eac5534cf4a4ba136
MD5 f8d868e2fdc72f06955d83c058b80a3a
BLAKE2b-256 cdf0030f22e8c5ea9a605a3ab087df96eaaaedf01e2bc952f5e7ef66821cc16a

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynojson-0.1.1-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: CI.yml on cykruss/dynojson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dynojson-0.1.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: dynojson-0.1.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 190.1 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dynojson-0.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b9f8b210440851a2acebd9a27a6db8a305c55e3b68bf29fe7bb61749657196da
MD5 c7a8b80311c86f214154b37a1ded8436
BLAKE2b-256 a9fa7635585ba106219f8d24b5c01065708fa7be28cba70a090ca1cb2f1dee92

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynojson-0.1.1-cp310-abi3-win_amd64.whl:

Publisher: CI.yml on cykruss/dynojson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dynojson-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dynojson-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fbdcf8f9f7b64cb7fdf25f56ec35086d5f82dd730c29b3c4ccbb679045d73eaa
MD5 50dba2b46b6032f181845b4b1d2b4b63
BLAKE2b-256 9d7eca7b93ec778aae7acb2989e6d117496aad0895834f81fefd4312650e4d45

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynojson-0.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: CI.yml on cykruss/dynojson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dynojson-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for dynojson-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fa0d03f4ac7914202170db89abc1f661fdc0bd12b862382a6623e79c7e4ce9bd
MD5 037bb7290ef729b96298eef43878dc23
BLAKE2b-256 fb19f4560a0ba80c0c85da85b60913d52a3e6a0a063c16cbb71063bf7a4ded4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynojson-0.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: CI.yml on cykruss/dynojson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dynojson-0.1.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dynojson-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2f701139ad5afe7b7053384fc553c5d3f7caf0082b373cb18d5506c7c270c0e1
MD5 81374e84249c6c1b935fc6e86ab1c536
BLAKE2b-256 6a070d51dd0ffe513149c9499d0c81bdd94c5ff85bfedf9ab403268d85c98e84

See more details on using hashes here.

Provenance

The following attestation bundles were made for dynojson-0.1.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: CI.yml on cykruss/dynojson

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page