Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Allows to serialize python classes into JSON objects and deserialize JSON objects into python classes

Project description

JSON Transform

Json Transform allows you to simply serialize your Python objects into a JSON format and vice versa.

New? Here is some help:


Setup your object.

from jsontransform import field, JsonObject

class Customer(JsonObject):
    def __init__(self):
        self._first_name = ""
        self._age = 0

    # set a custom name for the field becuase by default it will be the function name
    def first_name(self):
        return self._first_name

    def first_name(self, value):
        self._first_name = value

    def age(self):
        return self._age

    def age(self, value):
        self._age = value

Instantiate the object and serialize it.

new_customer = Customer()
new_customer.first_name = "Peter"
new_customer.age = 1

# get a dict representation of the object
# result: {"firstName": "Peter", "age": 1}

# we can also write the object directly into a file
with open("new_customer.json", "w") as f:

Deserialize a JSON file into your object.

JSON file (customer.json):

  "firstName": "Dennis",
  "age": 70


# we load our customer object
with open("customer.json", "r") as f:
    customer = Customer.from_json_file(f)

# result: 70

# result: Dennis


Check out the documentation.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
json_transform-0.1.5-py2-none-any.whl (11.4 kB) Copy SHA256 hash SHA256 Wheel py2
json-transform-0.1.5.tar.gz (9.9 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page