Skip to main content

Extract value from json via simple json path.

Project description

jvalue - extract json value

Extract values from json data via simplified json path.

Install

pip install jvalue

Example

from jvalue import JsonValue

artist = {
    "name": "David Bowie",
    "albums": [
        {"title": "Ziggy Stardust", "year": 1972},
        {"title": "Blackstar", "year": 2016},
    ],
}

jv = JsonValue(artist)

assert jv.find("$") == artist
assert jv.find("") == artist
assert jv.find("albums[].title") == ["Ziggy Stardust", "Blackstar"]
assert jv.find("albums[*].year") == [1972, 2016]
assert jv.find("albums[0].year") == 1972
assert jv.find("albums[2].year") is None

or, you can use json_extract as a function directly

from jvalue import json_extract

assert json_extract(artist, "albums[0].title") == "Ziggy Stardust"

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

jvalue-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jvalue-0.1.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file jvalue-0.1.0.tar.gz.

File metadata

  • Download URL: jvalue-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for jvalue-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ac790a85daa72a443e12aa9901e2a364bbc291e2f4560c137bde013fe9ee58ac
MD5 5280cc13d7d7d72061ce9ccf9569bbd3
BLAKE2b-256 1030102c8d0b2cb3e7f36584001d548e31db5c6ef8c74368796ea99c4e3b7577

See more details on using hashes here.

File details

Details for the file jvalue-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jvalue-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for jvalue-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0022701a8b9e033ed5253adeb3d031eab76f44d840a73b175b0f8c4682009d91
MD5 b0bac2bc2b6bec76119ee0a8a6c9adf4
BLAKE2b-256 0d4e1b25b2fb804a86753daf6c8997ab0aacfc31b02490afefe63e07b0687f38

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page