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
-
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.11.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file json_repr-1.1.11.tar.gz
.
File metadata
- Download URL: json_repr-1.1.11.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d05fd79bd60b47094644c84f1fe89f6097dbe220e833c1060bd8681c429aded7 |
|
MD5 | 92ad456e5d88987f7f6e6dc91af152a3 |
|
BLAKE2b-256 | 10ec69a59aaaeeb8adb44b8a19daaeeea2c00f3f52290b996fa80c835e09d69e |
File details
Details for the file json_repr-1.1.11-py3-none-any.whl
.
File metadata
- Download URL: json_repr-1.1.11-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8e6c86996bf48d3b55803832619f14bc7d2e7dc1831bd492aa12dc4960aaeef |
|
MD5 | 61df40746b441cacf12ce5f90ec6d945 |
|
BLAKE2b-256 | 93755a5012137736db1ca92fe4ed21e26820b1a5df2c12bf021ce44c303b8e7c |