Skip to main content

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


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 details)

Uploaded Source

Built Distribution

json_repr-1.1.12-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file json_repr-1.1.12.tar.gz.

File metadata

  • Download URL: json_repr-1.1.12.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

Hashes for json_repr-1.1.12.tar.gz
Algorithm Hash digest
SHA256 58539cde5be6e359a24b6b3a888b2c4aceade2d6942c12f674ebc3a5f534f443
MD5 ab7b8d6a81ca1354171e1bae434ea771
BLAKE2b-256 ca78c3896a73ad1b3657064ae6ac879e63c1e45464ff55f5a69874990f1f474c

See more details on using hashes here.

File details

Details for the file json_repr-1.1.12-py3-none-any.whl.

File metadata

  • Download URL: json_repr-1.1.12-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

Hashes for json_repr-1.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 be1eba8c4f9ed8c74c7c9f76d748a3e8e270ada3e4ee4d796069b91470bf367c
MD5 743d0e6c785db6f1393e27491d368702
BLAKE2b-256 404c2df856df8c4f099943a683288e859ff78b32238f43ef3a28e46adc26533d

See more details on using hashes here.

Supported by

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