Registry / aws / dynamo-json

dynamo-json

JSON →
library1.2.0pypypi✓ verified 84d ago

dynamo-json is a Python utility library (currently v1.2.0) designed to facilitate seamless conversion between standard Python objects (including Decimal, datetime, and UUID) and the specialized JSON format used by Amazon DynamoDB. It provides `dumps` and `loads` functions that mimic the standard `json` library, handling the DynamoDB type descriptors (e.g., {'S': 'string'}, {'N': '123'}) automatically. The library has been in maintenance mode since its last update in 2020, with a focus on stable functionality.

pip install dynamo-json
INSTALL
IMPORT
SIG · DYNAMO-JSON
D
dynamo-json
awspythonv1.2.0
Install
1.7s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.7s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

json
from dynamo_json import json
from dynamo_json import json_util as json
marshall
from dynamo_json import marshall
unmarshall
from dynamo_json import unmarshall

Demonstrates converting a complex Python dictionary containing Decimals, datetimes, and UUIDs to DynamoDB-compatible JSON and back. The `json_util` module handles the necessary type marshalling and unmarshalling.

import time import uuid from datetime import datetime from decimal import Decimal from dynamo_json import json_util as json # Python object with various types, including those requiring special handling by DynamoDB json_ = { "MyString": "a", "num": 4, "MyBool": False, "my_dict": {"my_date": datetime.now(), "my_uuid": uuid.uuid4()}, "MyList": [Decimal('1.23'), 2, 3], "MyNull": None } # Convert Python object to DynamoDB JSON format dynamo_json_data = json.dumps(json_) print("DynamoDB JSON:\n", dynamo_json_data) # Convert DynamoDB JSON format back to a Python object python_object = json.loads(dynamo_json_data) print("Python object:\n", python_object)
Debug
Known issues
gotchaThere is a similarly named but distinct library called `dynamodb-json` (with 'db') developed by Alonreznik, which also provides DynamoDB JSON conversion functionalities and uses a very similar import pattern (`from dynamodb_json import json_util as json`). Ensure you install `dynamo-json` (`pip install dynamo-json`) if you intend to use this specific library by adilosa, to avoid unexpected behavior or missing features from the wrong package.
fix
Always explicitly install `dynamo-json` if this specific library is desired, and verify the package source if encountering unexpected behavior.
affects: All
gotchaDynamoDB has a strict item size limit of 400KB. While `dynamo-json` handles the format conversion, it does not bypass this underlying DynamoDB constraint. Attempting to serialize very large Python objects will result in DynamoDB errors when `put_item` is called.
fix
For items exceeding 400KB, consider storing large attributes in Amazon S3 and referencing them in DynamoDB, or restructure your data model to break down large items into smaller ones.
affects: All
gotchaDynamoDB supports high-precision numbers (up to 38 digits) which are typically represented as strings in DynamoDB JSON (`{'N': '123.45'}`). This library correctly handles `Decimal` objects. If you process data outside of `dynamo-json`'s `dumps`/`loads` using standard JSON libraries, you might lose precision for large numbers or encounter `TypeError` for `Decimal` objects.
fix
Consistently use `dynamo_json.json_util.dumps()` and `loads()` for all DynamoDB-related JSON serialization/deserialization to ensure proper handling of numerical precision and other complex types like `datetime` and `UUID`.
affects: All
Upgrade
Version history
1.2.0latest on PyPI · released Jun 30, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
21
Amazon
1
Resources
dynamo-json — pip install dynamo-json · libregistry