Metadata-Version: 2.1
Name: d-serialize
Version: 1.0.5
Summary: Universal Python serializer
Home-page: https://github.com/Martlark/d_serialize
Author: Andrew Rowe
Author-email: rowe.andrew.d@gmail.com
License: Apache Software License
Download-URL: https://github.com/Martlark/d_serialize/archive/1.0.5.tar.gz
Keywords: serialize json convert dict
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS
Classifier: Operating System :: Unix
Classifier: Operating System :: Microsoft :: Windows
Description-Content-Type: text/markdown
License-File: LICENSE

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

