Skip to main content

A framework agnostic serialization and marshaling library written in python.

Project description

Kim is a framework agnostic serialization and marshaling (de-serilization) library for python web applications.

It helps you transform data from your ORM objects into JSON serializable dicts to output from your REST API.

In the other direction, you can use the exact same serializer definition to transform JSON POST data from your clients back into ORM objects to save in your database.

Kim can work with basic Python objects and dicts, and has an adapter for seamless intergration with SQLAlchemy. Django integration is coming soon.

Example

class Person(db.Model):
    name = Column(String)
    age = Column(Integer)

class MySerializer(SQASerializer):
    name = Field(String)
    current_age = Field(Integer, source='age')

person1 = db.session.query(Person).first()

>>> MySerializer().serialize(person)
{'name': 'jack', 'current_age': 24}

person2 = MySerializer().marshal({'name': 'mike', 'current_age': 28})

>>> person2.name
'mike'

>>> person2.age
28

Features

  • Serialization (output) and marshaling (input)

  • Automatic validation and sanitization of input when marshaling.

  • Declarative Serializer definition syntax

  • Flexible Types API - many common types built in or easily define your own

  • Support for roles - whitelist/blacklist fields for different use cases

  • Nested serializers including support for nested roles

  • Support for Collections, including Collections of Nested enabling a wide range of DB relationships to be directly mapped

  • Designed for extensibility - Serializers are syntactic sugar on top of an easy to understand low level API

Installation

pip install kim

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

py-kim-0.1.9.tar.gz (18.0 kB view hashes)

Uploaded Source

Supported by

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