json-repr


Namejson-repr JSON
Version 1.1.12 PyPI version JSON
download
home_page
SummaryHandle JSON like data structures with a "repr(...)" fallback, e.g. for MongoDB types
upload_time2023-09-05 23:07:28
maintainer
docs_urlNone
author
requires_python>=3.6
license
keywords json mongodb dumps eval repr
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # json-repr

Pretty print JSON like data structures with a "repr(...)" fallback, e.g. for MongoDB types

## Usage

```python
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

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "json-repr",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "JSON,MongoDB,dumps,eval,repr",
    "author": "",
    "author_email": "Carsten Lindner <Carsten.Lindner@gmx.net>",
    "download_url": "https://files.pythonhosted.org/packages/ca/78/c3896a73ad1b3657064ae6ac879e63c1e45464ff55f5a69874990f1f474c/json_repr-1.1.12.tar.gz",
    "platform": null,
    "description": "# json-repr\n\nPretty print JSON like data structures with a \"repr(...)\" fallback, e.g. for MongoDB types\n\n## Usage\n\n```python\nimport json_repr\n\n# JSON: Legacy Mongo Shell Format\noriginal_source = \"\"\"{\n    \"_id\": ObjectId(\"507f1f77bcf86cd799439011\"),\n    \"employees\": [\n        {\n            \"firstName\": \"Alice\",\n            \"middleName\": null,\n            \"id\": NumberInt(1),\n            \"active\": true\n        },\n        {\n            \"firstName\": \"Bob\",\n            \"middleName\": null,\n            \"id\": NumberInt(2),\n            \"active\": false\n        }\n    ]\n}\"\"\"\n\ndocument = json_repr.eval_mongo_db_json(original_source)\n\nprint(document[\"employees\"][0])\n\ndumped_source = json_repr.dumps(document)\nprint(dumped_source)\n\nprint(dumped_source == original_source)\n```\n\n## MongoDB\n\nCurrently supported (legacy) mongo shell types:\n\n* ObjectId\n* NumberInt\n* NumberLong\n* NumberDecimal\n\nand\n\n* null\n* true\n* false\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Handle JSON like data structures with a \"repr(...)\" fallback, e.g. for MongoDB types",
    "version": "1.1.12",
    "project_urls": {
        "Bug Tracker": "https://github.com/clxx/json-repr/issues",
        "Homepage": "https://github.com/clxx/json-repr"
    },
    "split_keywords": [
        "json",
        "mongodb",
        "dumps",
        "eval",
        "repr"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "404c2df856df8c4f099943a683288e859ff78b32238f43ef3a28e46adc26533d",
                "md5": "743d0e6c785db6f1393e27491d368702",
                "sha256": "be1eba8c4f9ed8c74c7c9f76d748a3e8e270ada3e4ee4d796069b91470bf367c"
            },
            "downloads": -1,
            "filename": "json_repr-1.1.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "743d0e6c785db6f1393e27491d368702",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 3518,
            "upload_time": "2023-09-05T23:07:27",
            "upload_time_iso_8601": "2023-09-05T23:07:27.261805Z",
            "url": "https://files.pythonhosted.org/packages/40/4c/2df856df8c4f099943a683288e859ff78b32238f43ef3a28e46adc26533d/json_repr-1.1.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca78c3896a73ad1b3657064ae6ac879e63c1e45464ff55f5a69874990f1f474c",
                "md5": "ab7b8d6a81ca1354171e1bae434ea771",
                "sha256": "58539cde5be6e359a24b6b3a888b2c4aceade2d6942c12f674ebc3a5f534f443"
            },
            "downloads": -1,
            "filename": "json_repr-1.1.12.tar.gz",
            "has_sig": false,
            "md5_digest": "ab7b8d6a81ca1354171e1bae434ea771",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4188,
            "upload_time": "2023-09-05T23:07:28",
            "upload_time_iso_8601": "2023-09-05T23:07:28.375709Z",
            "url": "https://files.pythonhosted.org/packages/ca/78/c3896a73ad1b3657064ae6ac879e63c1e45464ff55f5a69874990f1f474c/json_repr-1.1.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-05 23:07:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "clxx",
    "github_project": "json-repr",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "json-repr"
}
        
Elapsed time: 0.11459s