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-1.0.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

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

pydeclares-1.0.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydeclares-1.0.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.6.2

File hashes

Hashes for pydeclares-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c8befce48d1aca0b1c5a21a7e7cb8d1e136cec46b031aedba398963f92eeb344
MD5 c62605cc8f2afea51f0e0601266c4977
BLAKE2b-256 0b9b6bfe817fca7497ce27ed3cc0edcb0ac4bff28272ce0fa3fcbb1f8f555cd7

See more details on using hashes here.

File details

Details for the file pydeclares-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pydeclares-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.6.2

File hashes

Hashes for pydeclares-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6793385d98a18582008263db9c27f0c27c6257bbb0537357eb2dd02aed7f8e61
MD5 a613c929c7033ee4d4eefa063e9cf187
BLAKE2b-256 52b33a90933e9aec80748f5c897eb5322394bb6c05ef45b20ee25facc7fcfe76

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