Skip to main content

Convert dict to (js)object

Project description

dict2object

dict2object is a dictionary that supports attribute-style access, a la JavaScript.

>>> user = Object({
...     "name": "John",
...     "age": 18,
...     "job": {
...         "name": "programmer",
...         "experience": 5
...     }
... })
>>> user.name
'Jhon'
>>> user.job.name
'programmer'

Dictionary Methods

A dict2object is a subclass of dict; it supports all the methods a dict does:

>>> user.keys()
['name', 'age', 'job']

Serialization

Bunches happily and transparently serialize from JSON.

>>> user = Object.load('{"name": "Anna", "age": 20}')
>>> user.name
'Anna'

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

dict2object-gaponukz-0.0.1.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

dict2object_gaponukz-0.0.1-py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 3

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