Skip to main content

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

Metadata

Release files for object-get 0.0.1

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

Source distribution (sdist)

Source distribution for object-get 0.0.1
File Size Uploaded
object-get-0.0.1.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for object-get 0.0.1
File Interpreter ABI Platform
object_get-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 5.8 kB

Release files / object-get-0.0.1.tar.gz

Download URL object-get-0.0.1.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c55e1b0ab6ffccf7dcb0ec74f00091131bc7b90df8aca7ce52a007ce40b04a41
BLAKE2b-256 checksum
How to use checksums
a4672f8dedcef39d99e230d225ee472e6ea00599de8b4d442eb6b2adc6e3dbd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / object_get-0.0.1-py3-none-any.whl

Download URL object_get-0.0.1-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e895bae119a860ddd825313a4c29e718c14e433e83dacfe34aaadc5164d832ec
BLAKE2b-256 checksum
How to use checksums
5d0f009178b9e69de1921974b077b017e27a0eeb3534c4bbe02694f67457bde6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.0.1 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