Skip to main content

Search through JSON data key:vales by key

Project description

jsonparse

PyPI - Python Version) GitHub tag (latest SemVer) GitHub Workflow Status codecov


jsonparse is a simple JSON parsing library. Extract the values from key:value pairs providing the key(s).

Install

pip install jsonparse

Usage

from jsonparse import Parser

parse = Parser(stack_trace=False, queue_trace=False)
data = [
    {"key": 1},
    {"key": 2},
    {"my": 
        {"key": 
            {"chain":"A"}
        }
    }
]


print(parse.key(data, 'key'))
[{'chain': 'A'}, 2, 1]

print(parse.key_chain(data, ['my', 'key', 'chain']))
['A']

print(parse.key_chain(data, ['key']))
[1, 2]

API

key(data: dict | list, key: str): -> list

  • Provide JSON data as a dictionary or a list, as well as the key as a string
  • Returns a list of values that match the corresponding key.

key_chain(data: dict | list, keys: list): -> list

  • Provide JSON data as a dictionary or a list, as well as a list of keys as strings.
  • Returns a list of values that match the corresponding key chain.

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

jsonparse-0.5.1.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

jsonparse-0.5.1-py3-none-any.whl (4.9 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