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"),
    "persons": [
        {
            "name": "Alice",
            "id": NumberInt(1)
        },
        {
            "name": "Bob",
            "id": NumberInt(2)
        }
    ]
}"""

document = json_repr.eval_mongo_db_json(original_source)

print(document.persons[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

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.9.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: json_repr-1.1.9.tar.gz
  • Upload date:
  • Size: 4.1 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.9.tar.gz
Algorithm Hash digest
SHA256 122d7354a8d1c2e5db4d2ec590fc8035e320c26cc2ed91fa883284e9baa02648
MD5 cd23ace5b8cb778765020810c1ae4f04
BLAKE2b-256 8f1328130bf6c4a788894500dab83efef4bcd57af091c523073bb036861bc5af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: json_repr-1.1.9-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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 653b98066b61ba0fde881ce4d1b33a10fa3cd43826d341e9980397e2603fc830
MD5 fa849641bd79f498993bc1542ee878ba
BLAKE2b-256 bcabc67a5fda65b1303028392fdfb1f9dcf61f9400140ae1612acfa0ee17b7a5

See more details on using hashes here.

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