Metadata-Version: 2.1
Name: json-transform
Version: 0.4.1
Summary: Convert python objects to JSON objects and vice versa.
Home-page: https://bitbucket.org/Peter-Morawski/json-transform
Author: Peter Morawski
Author-email: contact@peter-morawski.de
License: MIT License
Keywords: convert python object json
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Operating System :: OS Independent
Classifier: Topic :: Communications
Classifier: Topic :: Software Development
Classifier: Topic :: Utilities
Description-Content-Type: text/markdown
Requires-Dist: decorator (==4.3.0)
Requires-Dist: python-dateutil

# JSON Transform

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

New? Here is some help:

* [Getting Started](https://json-transform.readthedocs.io/en/latest/getting-started.html#getting-started)

### Example

Setup your object.

```python
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
    @property
    @field("firstName")
    def first_name(self):
        return self._first_name

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

    @property
    @field()
    def age(self):
        return self._age

    @age.setter
    def age(self, value):
        self._age = value
```

Instantiate the object and serialize it.

```python
from jsontransform import Serializer

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

# get a dict representation of the object
# result: {"firstName": "Peter", "age": 1}
Serializer.to_json_dict(new_customer)

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

Deserialize a JSON file into your object.

**JSON file (customer.json):**

```json
{
  "firstName": "Dennis",
  "age": 70
}
```

**Code:**

```python
from jsontransform import Deserializer

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

customer.age
# result: 70

customer.first_name
# result: Dennis
```

### More

* Check out the [documentation](https://json-transform.readthedocs.io/en/latest/).
* Check out the [history](https://bitbucket.org/Peter-Morawski/json-transform/src/master/HISTORY.md)


