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

Uploaded Source

File details

Details for the file dict2object-gaponukz-0.0.2.tar.gz.

File metadata

  • Download URL: dict2object-gaponukz-0.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.0

File hashes

Hashes for dict2object-gaponukz-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5baa7bf31e1315a55b8af738c6e3b3d477fab6bd895f6044451cc6b8ec07429f
MD5 9532bf887e321de5fde87ec219969fad
BLAKE2b-256 4c8ea3d14368f7fc4e9b42b1d9b14db700dd5be52017963daf58b78b4f586072

See more details on using hashes here.

Provenance

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