linw1995 / jsonpath Goto Github PK
View Code? Open in Web Editor NEWA query expression for extracting data from JSON.
Home Page: https://jsonpath.rtfd.io/en/latest/
License: MIT License
A query expression for extracting data from JSON.
Home Page: https://jsonpath.rtfd.io/en/latest/
License: MIT License
Probably it's intreehooks causing this problem. Sdist (Source distribution) of poetry and pdm built by using the intreehooks is not working with pip too. The elder version 0.12.17 of poetry, without using intreehooks, is working well with pip.
Add --ensure-ascii
argument, default: --ensure-ascii=false
Add a Github action to build a stand-alone parser. And publish it to PyPI without lark-parser dep.
The build.py
file contaminates the site-packages directory after installing jsonpath-extractor.
build.py
is for doing code-gen, generating the standalone parser via lark-parser.
And it is to be run for building dist-wheel or for installing the source code.
build.py
as a module of the jsonpath package.build.py
as a submodule of the jsonpath namespace package.Hi and thank you for putting together this really helpful package!
I have a use case where I would like to keep matched objects synchronized.
For instance, using the data from the documentation:
from jsonpath import parse
data = {
"goods": [
{"price": 100, "category": "Comic book"},
{"price": 200, "category": "magazine"},
{"price": 200, "no category": ""}
],
"targetCategory": "book"
}
I would like to extract price
and category
keys into lists, but lists must have same lengths.
The following expression:
parse("$.goods[*].category").find(data)
outputs all matching items (which is already super cool :)) :
['Comic book', 'magazine',]
Is there a way to add 'None' for array items that do not contain the category
key? I.e. having the following output:
['Comic book', 'magazine', None]
(Or any other way to achieve the desired result?)
Hi!,
I have the following JSON:
[{
"author": [
{
"fullname": "some fullname",
"rank": 3
},
{
"fullname": "other fullname",
"pid": {
"id": {
"scheme": "orcid",
"value": "0000-0000-0000-0000"
},
"provenance": {
"provenance": "Harvested",
"trust": "0.91"
}
},
"rank": 4
}
]
}]
and the following jsonpath expression:
$.*.author[*]
But I get empty results, which is not the same behaviour online tool.
Thank you in advance! :)
Also, Python 3.6 is widely used.
Implements a simple and easy for usage syntax for object conversion.
assert parse("${a:b, b:a}") \
.find({"a": 1, "b": 2}) == [{"b": 1, "a": 2}], "swaps values between a and b"
assert parse("${username:author_name, age:author_age}") \
.find({
"author_name": "Jade",
"author_age": 18,
"boo": "boo"
}) == [{"username": "Jade", "age": 18}], "Rearranges the key-value pairs"
assert parse("$[{a:b}]").find([{"b": 1}, {"c": 1}]) == [{"a": 1}, {"a": None}]
assert parse("$[{a:b}][a != null]").find([{"b": 1}, {"c": 1}]) == [{"a": 1}]
assert parse("${author: {name: author_name}}") \
.find({"author_name": "Jade"}) == [{"author": {"name": "Jade"}}]
Or the key of the key-value pair may be chained path which components are name only, e.g. boo.bar
assert parse("${author.name: author_name}") \
.find({"author_name": "Jade"}) == [{"author": {"name": "Jade"}}]
assert parse("${name: author.name}") \
.find({"author": {"name": "Jade"}}) == [{"name": "Jade"}]
Hi!
I have the following data:
[
{
"title":[
"some title"
],
"creator":[
{
"fullname":"WWWW ZZZZ",
"name":"WWWW",
"surname":"ZZZZ"
},
{
"fullname":"XXXX YYYY",
"name":"XXXX",
"surname":"YYYY"
}
],
"id":2157
}
]
Is the expression $[*].(title,id)
supported (with other syntax)?
Thanks in advance :)
Julián
Using type stub files to make static type checking instead of using annotations from source codes.
typing-extensions
dependency from production release....
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.