Skip to main content

JSON de/serializers

Project description

json-serde

PyPI Version CI Documentation Status

JSON de/serializer for Python, inspired by attrs and SQLAlchemy.

Example

import requests
from json_serde import JsonSerde, Integer, String, IsoDateTime


class User(JsonSerde):
    username = String()
    user_id = Integer(rename='userId')
    birthday = IsoDateTime(is_optional=True, default=None)


resp = requests.get('https://example.com/api/user')
resp.raise_for_status()

api_response = resp.json()
# {'username': 'emmag', 'userId': 1312, 'somethingElse': ['irrelevant']}

user = User.from_json(api_response)
assert user.username = 'emmag'
assert isinstance(user.user_id, int)
assert user.birthday is None

License

This work is dual licensed under the MIT and Apache-2.0 licenses. See LICENSE-MIT and LICENSE-APACHE for details.

Project details


Download files

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

Source Distribution

json-serde-0.0.9.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

json_serde-0.0.9-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file json-serde-0.0.9.tar.gz.

File metadata

  • Download URL: json-serde-0.0.9.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.12.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.3

File hashes

Hashes for json-serde-0.0.9.tar.gz
Algorithm Hash digest
SHA256 eae7dbb303a9314f8b42d7800b185e8d4fdc5bb8966c408c50adfd43cc71c1f6
MD5 eb96f3b4a55f8be6325280807e252ccf
BLAKE2b-256 d5736ba7aa0db9ec1d790a27dd60c5461c906789a59ef7a3ab56e9b13f45b0df

See more details on using hashes here.

File details

Details for the file json_serde-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: json_serde-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.12.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.3

File hashes

Hashes for json_serde-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 c705852200bc2d93954f78e969c72a0ef1c3193e10ed2239ad72243115412a56
MD5 747df2e6560750221e8f2c40640698c1
BLAKE2b-256 b6caff05f93770959ab387f9b0c1e2700d521c38daed78e9a978b556ca2a79c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page