Handle JSON like data structures with a "repr(...)" fallback, e.g. for MongoDB types
Project description
json-repr
Pretty print JSON like data structures with a "repr(...)" fallback, e.g. for MongoDB types
Usage
import json_repr
# JSON: Legacy Mongo Shell Format
original_source = """{
"_id": ObjectId("507f1f77bcf86cd799439011"),
"employees": [
{
"firstName": "Alice",
"middleName": null,
"id": NumberInt(1),
"active": true
},
{
"firstName": "Bob",
"middleName": null,
"id": NumberInt(2),
"active": false
}
]
}"""
document = json_repr.eval_mongo_db_json(original_source)
print(document["employees"][0])
dumped_source = json_repr.dumps(document)
print(dumped_source)
print(dumped_source == original_source)
MongoDB
Currently supported (legacy) mongo shell types:
- ObjectId
- NumberInt
- NumberLong
- NumberDecimal
and
- null
- true
- false
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
json_repr-1.1.12.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for json_repr-1.1.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be1eba8c4f9ed8c74c7c9f76d748a3e8e270ada3e4ee4d796069b91470bf367c |
|
MD5 | 743d0e6c785db6f1393e27491d368702 |
|
BLAKE2b-256 | 404c2df856df8c4f099943a683288e859ff78b32238f43ef3a28e46adc26533d |