Skip to main content

jsonpath-kv

pip install jsonpath-kv
from jsonpath_kv import jsonvalue

正常的dict

user_dict = {
    "sites":
        [
            { "name":"runoob" , "url":"www.runoob.com" },
            { "name":"google" , "url":"www.google.com" },
            { "name":"weibo" , "url":"www.weibo.com" }
        ]
}
r = jsonvalue.get(user_dict,'url')
print(r)
output: ['www.runoob.com', 'www.google.com', 'www.weibo.com']

json字符串

user_json = '{ "sites": [ { "name":"runoob" , "url":"www.runoob.com" }, { "name":"google" , "url":"www.google.com" }, { "name":"weibo" , "url":"www.weibo.com" } ] }'
r = jsonvalue.get(user_dict,'url')
print(r)
output: ['runoob', 'google', 'weibo']

当所取key在字符串包裹里时

user_json = { "sites": '[ { "name":"runoob" , "url":"www.runoob.com" }, { "name":"google" , "url":"www.google.com" }, { "name":"weibo" , "url":"www.weibo.com" } ]'}
r = jsonvalue.get(user_dict,'url')
print(r)
output: ['runoob', 'google', 'weibo']

当所取key在字符串包裹里时

user_dict = {"sites": "{ \"name\":\"google\" , \"url\":\"www.google.com\" }"}
r = jsonvalue.get(user_dict,'name')
print(r)
output: ['google']

key不存在时返回false

user_dict = {"sites": "{ \"name\":\"google\" , \"url\":\"www.google.com\" }"}
r = jsonvalue.get(user_dict, 'address')
print(r)
output: False

Metadata

Release files for jsonpath-kv 0.0.8

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

Source distribution (sdist)

Source distribution for jsonpath-kv 0.0.8
File Size Uploaded Provenance Actions
jsonpath-kv-0.0.8.tar.gz 2.1 kB Without provenance Details for jsonpath-kv-0.0.8.tar.gz

Release files / jsonpath-kv-0.0.8.tar.gz

Download URL jsonpath-kv-0.0.8.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0a6ccbb67998bd4f876f7ce13de9c7104c933213a3171289d1489828293e3425
BLAKE2b-256 checksum
How to use checksums
55296040385cb051405687549c8d456b405628610eee7458870d06d5f46eae30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.8

Security for jsonpath-kv 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.8 This release

1 release file No provenance

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