Skip to main content

Use "." to get the value of a JSON object. Just like JavaScripthat gets the value of an object

Project description

object-get

Use "." to get the value of a JSON object. Just like JavaScripthat gets the value of an object

Install

pip install object-get

Usage

from object_get import get

obj = {
    'age': 18,
    'name': {
        'first': 'John',
        'last': 'Doe'
    },
    'languages': [
        'python',
        'java',
        ['c', 'c++'],
        ['js', 'javascript', 'typescript']
    ]
}

print(get(obj, 'age'))
# => 18

print(get(obj, 'weight'))
# => None

print(get(obj, 'weight', 100))
# => 100
- print(obj['name']['first'])
+ print(get(obj, 'name.first'))
# => John

- print(obj['name']['last'])
+ print(get(obj, 'name.last'))
# => Doe

- print(obj['languages'][0])
+ print(get(obj, 'languages[0]'))
# => python

- print(obj['languages'][2][1])
+ print(get(obj, 'languages[2][1]'))
# => c++

- print(obj['languages'][3][2])
+ print(get(obj, 'languages[3][2]'))
# => typescript

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

object-get-0.0.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

object_get-0.0.1-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file object-get-0.0.1.tar.gz.

File metadata

  • Download URL: object-get-0.0.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for object-get-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c55e1b0ab6ffccf7dcb0ec74f00091131bc7b90df8aca7ce52a007ce40b04a41
MD5 6871ecee212b785c6ea20e3cfabfb8a1
BLAKE2b-256 a4672f8dedcef39d99e230d225ee472e6ea00599de8b4d442eb6b2adc6e3dbd6

See more details on using hashes here.

File details

Details for the file object_get-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: object_get-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for object_get-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e895bae119a860ddd825313a4c29e718c14e433e83dacfe34aaadc5164d832ec
MD5 c6502b9c1c134babd43f6eaad1778c6c
BLAKE2b-256 5d0f009178b9e69de1921974b077b017e27a0eeb3534c4bbe02694f67457bde6

See more details on using hashes here.

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