d-serialize


Named-serialize JSON
Version 1.0.5 PyPI version JSON
download
home_pagehttps://github.com/Martlark/d_serialize
SummaryUniversal Python serializer
upload_time2023-09-03 10:01:10
maintainer
docs_urlNone
authorAndrew Rowe
requires_python
licenseApache Software License
keywords serialize json convert dict
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            d_serialize

===========



Universal converter of all things Python to a `dict`.  So it can be serialized

to `JSON`. 



Install

-------



pip install d-serialize



Usage:

------



```python

from d_serialize import d_serialize

from objects import SomeObject



some_object = SomeObject()

json_values = d_serialize(some_object)

```



Usage in Flask

--------------



```python

from d_serialize import d_serialize

from flask import jsonify

from objects import SomeObject



@app.route('/a_route')

def a_route():

    some_object = SomeObject()

    json_values = d_serialize(some_object)

    return jsonify(json_values)

```



d_serialize will enumerate all public properties of your object, set, list or `dict` and convert them

to a JSON allowable type.  IE:



    list, dictionary, string, float, integer or boolean.



Any property that is not one of these types will be converted to a `string`. Enumerables: `set`

and `tuple` will be converted to `list`.



Dictionary and list properties will be followed to ensure all child objects and

values are also converted.



Methods and private properties (starting with `_`) are not enumerated.



Any property or attribute that raises an exception will be excluded or

have a `None` value.



Example:

--------



Converting a Class instance.



```python

from d_serialize import d_serialize



class TestObject:

    number_value = 1

    float_value = 1.1



    def dont_call_me(self):

        """return self.number_value"""



print(d_serialize(TestObject()))



# dict(number_value=1, float_value=1.1)

```



Release History

===============



* 1.0.0 First version of this wondrous package.

* 1.0.1 Check for None when serializing and return None rather than 'None'.  Exceptions on getattr return None for value.

* 1.0.2 Crummy circular reference test.  Convert top level list, set, tuple.

* 1.0.3 Fix deploy workflow

* 1.0.4 Allow for readonly objects


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Martlark/d_serialize",
    "name": "d-serialize",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "serialize json convert dict",
    "author": "Andrew Rowe",
    "author_email": "rowe.andrew.d@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/49/92/df0aef95c3b8434d32a74792511eb301b9275df24be4f2705c9ebb652c24/d-serialize-1.0.5.tar.gz",
    "platform": null,
    "description": "d_serialize\n\n===========\n\n\n\nUniversal converter of all things Python to a `dict`.  So it can be serialized\n\nto `JSON`. \n\n\n\nInstall\n\n-------\n\n\n\npip install d-serialize\n\n\n\nUsage:\n\n------\n\n\n\n```python\n\nfrom d_serialize import d_serialize\n\nfrom objects import SomeObject\n\n\n\nsome_object = SomeObject()\n\njson_values = d_serialize(some_object)\n\n```\n\n\n\nUsage in Flask\n\n--------------\n\n\n\n```python\n\nfrom d_serialize import d_serialize\n\nfrom flask import jsonify\n\nfrom objects import SomeObject\n\n\n\n@app.route('/a_route')\n\ndef a_route():\n\n    some_object = SomeObject()\n\n    json_values = d_serialize(some_object)\n\n    return jsonify(json_values)\n\n```\n\n\n\nd_serialize will enumerate all public properties of your object, set, list or `dict` and convert them\n\nto a JSON allowable type.  IE:\n\n\n\n    list, dictionary, string, float, integer or boolean.\n\n\n\nAny property that is not one of these types will be converted to a `string`. Enumerables: `set`\n\nand `tuple` will be converted to `list`.\n\n\n\nDictionary and list properties will be followed to ensure all child objects and\n\nvalues are also converted.\n\n\n\nMethods and private properties (starting with `_`) are not enumerated.\n\n\n\nAny property or attribute that raises an exception will be excluded or\n\nhave a `None` value.\n\n\n\nExample:\n\n--------\n\n\n\nConverting a Class instance.\n\n\n\n```python\n\nfrom d_serialize import d_serialize\n\n\n\nclass TestObject:\n\n    number_value = 1\n\n    float_value = 1.1\n\n\n\n    def dont_call_me(self):\n\n        \"\"\"return self.number_value\"\"\"\n\n\n\nprint(d_serialize(TestObject()))\n\n\n\n# dict(number_value=1, float_value=1.1)\n\n```\n\n\n\nRelease History\n\n===============\n\n\n\n* 1.0.0 First version of this wondrous package.\n\n* 1.0.1 Check for None when serializing and return None rather than 'None'.  Exceptions on getattr return None for value.\n\n* 1.0.2 Crummy circular reference test.  Convert top level list, set, tuple.\n\n* 1.0.3 Fix deploy workflow\n\n* 1.0.4 Allow for readonly objects\n\n",
    "bugtrack_url": null,
    "license": "Apache Software License",
    "summary": "Universal Python serializer",
    "version": "1.0.5",
    "project_urls": {
        "Download": "https://github.com/Martlark/d_serialize/archive/1.0.5.tar.gz",
        "Homepage": "https://github.com/Martlark/d_serialize"
    },
    "split_keywords": [
        "serialize",
        "json",
        "convert",
        "dict"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f73132d89ba0066f2b66ac7b2d24dd5e832cf639b14c6e61bf8bfdc3fcccc039",
                "md5": "276e5874104cde9f584f7951be6c6749",
                "sha256": "dc33902df0deeb2cf4a455e60024f4df07b3faefeb644e1a73d9df749d342634"
            },
            "downloads": -1,
            "filename": "d_serialize-1.0.5-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "276e5874104cde9f584f7951be6c6749",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 4287,
            "upload_time": "2023-09-03T10:01:08",
            "upload_time_iso_8601": "2023-09-03T10:01:08.986487Z",
            "url": "https://files.pythonhosted.org/packages/f7/31/32d89ba0066f2b66ac7b2d24dd5e832cf639b14c6e61bf8bfdc3fcccc039/d_serialize-1.0.5-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4992df0aef95c3b8434d32a74792511eb301b9275df24be4f2705c9ebb652c24",
                "md5": "2b67e1cb52c84716f3d3dfe8c2a69958",
                "sha256": "6447dab5fc500b4e0e38c7c7727544ea9ce73f8bc7cf4a55f4960bfcd29e9237"
            },
            "downloads": -1,
            "filename": "d-serialize-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "2b67e1cb52c84716f3d3dfe8c2a69958",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5577,
            "upload_time": "2023-09-03T10:01:10",
            "upload_time_iso_8601": "2023-09-03T10:01:10.584679Z",
            "url": "https://files.pythonhosted.org/packages/49/92/df0aef95c3b8434d32a74792511eb301b9275df24be4f2705c9ebb652c24/d-serialize-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-03 10:01:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Martlark",
    "github_project": "d_serialize",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "d-serialize"
}
        
Elapsed time: 0.47733s