Skip to main content

A tool for provide format and serialize support to json, xml, form data and query string.

Project description

PyDeclares

This library provides a simple API for encoding and decoding declared classes to and from JSON, XML, FORM-DATA or QueryString.

It's very easy to get started.

Quickstart

pip install pydeclares

from pydeclares import var, Declared

class Person(Declared):
	name = var(str)
	age = var(int)

# decode json string
data = '{"name": "Tom", "age": 18}'
person = Person.from_json(data)

assert person.name == "Tom"
assert person.age == 18

# you can encode to xml after decode json string
result = person.to_xml()

assert result == '<person><name>Tom</name><age>18</age></person>'

# or form-data
result = person.to_form_data()

assert result == "name=Tom&age=18"

# or query string
person = Person(name="tom@a", age=18)
result = person.to_query_string()

assert result == "name=tom%40a&age=18"

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

pydeclares-0.5.tar.gz (10.2 kB view details)

Uploaded Source

File details

Details for the file pydeclares-0.5.tar.gz.

File metadata

  • Download URL: pydeclares-0.5.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for pydeclares-0.5.tar.gz
Algorithm Hash digest
SHA256 c2fccafcdf5694ccd07a6f601a38bfb9d8b2008e7a7c63452a7051ac46a7f90f
MD5 281354e19fb17a058d46f01bab6265ca
BLAKE2b-256 76c5fadfca4c71d35394df95194da4cae2fdd9c2ce0afdc88cd819a3535bee10

See more details on using hashes here.

Supported by

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