Skip to main content

Readable serializable and deserializable Python nested models

Project description


An eloquent and opinionated python library for nested object models definition offering simple serialization and deserialization into python dictionaries.

Build Status Codacy Badge Code style: black License: MIT


The deserialization of JSON or yaml into python data types is a common practice useful in many ways.

  • Configuration file reading and writing
  • REST API message response generation and request processing
  • Object-Document Mapping for a document store
  • Data import parsing or export generation


JStruct leverage attrs the great Classes without boilerplate library to define structs without boilerplate.


The result is a simple and intuitive syntax familiar to a pythonista that brings Validation, Deserialization and Serialization.


  • Python 3.6 and +


Install using pip

pip install jstruct


import attr
from typing import List
from jstruct import struct, JList

class Person:
    first_name: str
    last_name: str

class RoleModels:
    scientists: List[Person] = JList[Person]

payload = {
    "scientists": [{"first_name": "John", "last_name": "Doe"}] 

role_models = RoleModels(**payload)


# RoleModels(scientists=[Person(first_name='John', last_name='Doe')])


# {'scientists': [{'first_name': 'John', 'last_name': 'Doe'}]}



Contributors are welcomed.


This project is licensed under the MIT License - see the file 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.

Files for jstruct, version 2020.4.0
Filename, size File type Python version Upload date Hashes
Filename, size jstruct-2020.4.0-py3-none-any.whl (5.2 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page