Skip to main content

A selector expression for extracting data from JSON.

Project description

license Pypi Status Python version Package version PyPI - Downloads GitHub last commit Code style: black Build Status codecov

A selector expression for extracting data from JSON.

Quickstarts

Installation

Install the stable version from PYPI.

pip install jsonpath-extractor

Or install the latest version from Github.

pip install git+https://github.com/linw1995/jsonpath.git@master

Usage

import json

from jsonpath import parse, Root, Contains, Self

data = json.loads(
    """
    {
        "goods": [
            {"price": 100, "category": "Comic book"},
            {"price": 200, "category": "magazine"},
            {"price": 200, "no category": ""}
        ],
        "targetCategory": "book"
    }
"""
)
expect = [{"price": 100, "category": "Comic book"}]

assert parse("$.goods[contains(@.category, $.targetCategory)]").find(data) == expect

assert (
    Root()
    .Name("goods")
    .Array(Contains(Self().Name("category"), Root().Name("targetCategory")))
    .find(data)
    == expect
)

Changelog

  • 35f0960 New:Add release actions for pypi and gh-release

  • ce022b6 New:Add codecov for code coverage report

  • 7f4fe3c Fix:The reduce/reduce conflicts

  • 258b0fa Fix:The shift/reduce conflicts

  • 95f088d New:Add Github Actions for CI

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

jsonpath-extractor-0.1.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

jsonpath_extractor-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file jsonpath-extractor-0.1.1.tar.gz.

File metadata

  • Download URL: jsonpath-extractor-0.1.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.8.0 Linux/5.0.0-1027-azure

File hashes

Hashes for jsonpath-extractor-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3cfc86c109aaba149f2ec6df48efab0cfc45edcd50522866ee736bb1654d33eb
MD5 d342dba276ec8febd98af1c68c0f6dc3
BLAKE2b-256 64b26370133599804729d9d9f88eacf398a77602c44ea4b7f5643d06f6de8042

See more details on using hashes here.

File details

Details for the file jsonpath_extractor-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jsonpath_extractor-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.0 CPython/3.8.0 Linux/5.0.0-1027-azure

File hashes

Hashes for jsonpath_extractor-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ec995489d56e68a6432d5cf38f0becd506e56bc4329dc6c7aa753dc9733e318
MD5 c894b2f045dac5322a7546d6e7c2dc6e
BLAKE2b-256 9efd84a23640ac79d3c5bb7b282f69d28e0c769d3209a302364ca872e540c2d9

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