Comments (17)
No, there's no support for slurp. Mind if I ask what your use case is?
from jq.py.
I am trying to combine multiple JSON arrays (in strings) into one, and
while reading on the jq documentation, which I am already using for its
more common uses, I noticed the "slurp" option.
On Fri, Jan 15, 2016 at 6:35 PM Michael Williamson [email protected]
wrote:
No, there's no support for slurp. Mind if I ask what your use case is?
—
Reply to this email directly or view it on GitHub
#17 (comment).
from jq.py.
By looking further into the manual, I found that .[0] + .[1]
does exactly what I need.
from jq.py.
Can this get re-opened? My use case is to replace Subprocess calls to jq
by using this extension. This requires that the extension offer the same feature set as the command line binary. Just from a short look into the source code of jq
it should being possible to use the slurp mode with the library.
from jq.py.
What's your use case? Just trying to understand why explicitly passing in an array wouldn't work.
from jq.py.
Let's say you have this input:
{"name":"Bob Dylan", "tags":"{Artist}{Singer}"}{"name": "Michael Jackson"}
which is not valid json but a stream of valid json objects. The following jq
command:
jq -s . input.txt
gives you a valid json array:
[
{
"name": "Bob Dylan",
"tags": "{Artist}{Singer}"
},
{
"name": "Michael Jackson"
}
]
from jq.py.
Ah, I see. Seems reasonable. I don't really have time to add new functionality, but feel free to make a pull request.
from jq.py.
@mwilliamson Ok. Let me dig into it.. I'll give my best! :)
from jq.py.
This relates to --slurpfile
which allows reading in and processing multiple files. The can be referred to using variables in the jq filter:
jq -n --slurpfile old $1 --slurpfile new $2 '{old: $old[0], new: $new[0]}'
If someone was working on slurp functionality, it may be worth considering this as well.
My use case is computing a JSON that represents something like the diff between old and new.
from jq.py.
+1 - I was using this library through urlwatch
and wanted to be able to slurp as I'm handling a list of objects (not wrapped in an array) from an HTTP endpoint
from jq.py.
I've added slurp functionality and released a prerelease version to PyPI. Feedback would be welcome!
from jq.py.
@mwilliamson any plans on releasing the slurp-enabled version as a full release?
from jq.py.
As above, some feedback would be useful to know if the current implementation actually solves the problem or not before making a release.
from jq.py.
Well, don't know about the case above but it certainly works for me and works as expected 🙂
from jq.py.
This has now been released as part of 1.5.0.
from jq.py.
Thanks, @mwilliamson! 🎉
From the code, I gather that referring to different inputs using variables in the jq filter, like in jq
, hasn't been implemented:
jq -n --slurpfile old $1 --slurpfile new $2 '{old: $old[0], new: $new[0]}'
Is that right? -- I can open a separate feature request issue for that, just would like to make sure.
(My use case is computing a JSON that represents something like the diff between two inputs, which currently requires invocation of jq
as a separate process.)
from jq.py.
Correct, the change is only to add the slurp
argument to input_text()
.
from jq.py.
Related Issues (20)
- ImportError on arm64 (Mac OSX M1) with jq 1.5.0 and 1.6.0 HOT 7
- install error HOT 1
- Specify jq command-line options HOT 2
- Add type hints as a `.pyi` stub file
- json.dumps: ensure_ascii
- Is it possible to input_file? HOT 1
- how can I package this so that it can be reused as Lambda Layer in AWS? HOT 1
- 'OverflowError: cannot convert float infinity to integer' when handling big numbers HOT 3
- walk built-in function does not work HOT 1
- Output values truncated on "null bytes" HOT 2
- Is there a way to output query result without quotes (i.e. "jq -r ") HOT 1
- Error building wheel for jq during "pip install jq" HOT 1
- Cython-3 support HOT 3
- Tests failing with jq-1.7 HOT 1
- Useless `-lonig` when building using system libraries HOT 1
- Behaviour of Out Method first() on JSON Array Output HOT 1
- tox.ini missing in sdist - please add HOT 1
- Variable support
- Module support HOT 1
- Logging support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jq.py.