Skip to main content

py-jobject

A package to easily convert between Python objects and JSON-compatible dictionaries, with built-in type conversion.

Usage

  • Declare a class with type-annotated attributes:
class MyObject:

    foo: int
    bar: str
  • Convert to a dict object:
from py_jobject import to_dict

obj = MyObject()
obj.foo = 123
obj.bar = 'abc'

my_dict = to_dict(obj)

assert my_dict == {
   'foo': 123,
   'bar': 'abc'
}
  • Convert from a dict object:
from py_jobject import from_dict

my_dict = {
    'foo': 123,
    'bar': 'abc'
}

obj = from_dict(obj, MyObject)

assert obj.foo == 123
assert obj.bar == 'abc'

Features

  • Supports type conversion:
from py_jobject import from_dict

my_dict = {
    'foo': '123',
}

obj = from_dict(obj, MyObject)

assert obj.foo == 123

Release files for py-jobject 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-jobject 0.1.0
File Size Uploaded
py-jobject-0.1.0.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-jobject 0.1.0
File Interpreter ABI Platform
py_jobject-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.3 kB

Release files / py-jobject-0.1.0.tar.gz

Download URL py-jobject-0.1.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8ac12546f56045c547189b55d5499a28ce29fafc2075b81e3241e835f2ddbf33
BLAKE2b-256 checksum
How to use checksums
f3c6dc7878544e2deb56caa3cdd49f877f31ebab87f024a4f7cdfa8615f2c23e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

Release files / py_jobject-0.1.0-py3-none-any.whl

Download URL py_jobject-0.1.0-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dbef99fd2254d88664417f29dfd821925aa34297955fdede29dfccd30e531e39
BLAKE2b-256 checksum
How to use checksums
d33ef74c312b6c1e7ce1d89b4690b7629ea20e430936d256bfe23e5dee625ffe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page