Skip to main content
PyCon US is happening May 14th-22nd in Pittsburgh, PA USA.  Learn more

A XML, JSON,... decode library

Project description

PyDecoder

https://img.shields.io/pypi/v/pydecoder.svg https://img.shields.io/travis/iodevs/pydecoder.svg Documentation Status Updates https://coveralls.io/repos/github/iodevs/pydecoder/badge.svg?branch=master

A XML, JSON,… decode library

Features

  • Decode and validate values from XML and JSON.

Install

To install PyDecoder, run this command in your terminal:

$ pip install pydecoder

Example

>>> from pydecoder.fields import required, optional
>>> from pydecoder.json import to_int, to_string, decode

# Define data
>>> data = {'foo': 'Text', 'bar': 1}

# Describe data
>>> decoders = [
...     required('foo', to_string),
...     required('bar', to_int),
...     optional('baz', to_int, -5),
... ]

# Decode/verify data
>>> decode(lambda x: x, decoders, data)
Result(status='Ok', value=['Text', 1, -5])

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2017-05-21)

  • First release on PyPI.

Supported by

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