Skip to main content

d_serialize

===========

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

to JSON.

Install


pip install d-serialize

Usage:


from d_serialize import d_serialize

from objects import SomeObject



some_object = SomeObject()

json_values = d_serialize(some_object)

Usage in Flask


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, set, tuple 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.

Complex objects that refer to themselves will have their str value as the

recursive value instead of the entire complex value.

Example:


Converting a Class instance.

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

  • 1.0.6 Improve recursion check and value

Metadata

Release files for d-serialize 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for d-serialize 1.0.6
File Size Uploaded
d-serialize-1.0.6.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for d-serialize 1.0.6
File Interpreter ABI Platform
d_serialize-1.0.6-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 9.9 kB

Release files / d-serialize-1.0.6.tar.gz

Download URL d-serialize-1.0.6.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
754bbeca981fa9dc8d59186869ad73d1baba0773951970b0740a785ce5fe80da
BLAKE2b-256 checksum
How to use checksums
7110fbd34511fe578305ca7750d8bfe5965671c4c10914ed6bc10ffb8855cc50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.5

Release files / d_serialize-1.0.6-py2.py3-none-any.whl

Download URL d_serialize-1.0.6-py2.py3-none-any.whl
Size 4.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d56ee056ec2555b5a41ae2f0becfe648cff83f70a9c17d07a6d493a4888be822
BLAKE2b-256 checksum
How to use checksums
ea70401aa42f3ac674698aed9493c45313b18a7d72cf86bfe9742ada47f0453c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page