Comments (6)
Actually, since your case doesn't need synchronous application of the function, you should use jq.promised.raw().then(...)
instead, to prevent stupid errors.
from jq-web.
Although it is already possible to call jq with arguments (I just don't document it because it doesn't work for most arguments) I believe your case will be nicely served by jq.raw()
. Have you seen it?
from jq-web.
@fiatjaf thx for the fast reply!
I actually saw it in your test and tried to use it, but I kind of failed.
Wanted to have it here: https://github.com/zalando-incubator/bro-q/blob/master/src/ts/background.js#L4
from jq-web.
Have you tried this?
function getJq(jsonInput, filter = '.') {
- return jq(JSON.parse(jsonInput), filter);
+ return jq.raw(jsonInput, filter);
}
from jq-web.
@fiatjaf I thought I did but I will try again, maybe I have some other issues
Thanks also for the tipp with promised, this was an hackweek project and I'm actually a java backend dev trying to get into something new :)
from jq-web.
from looking at generated code, the third parameter is for options.
like
jq.promised.raw(jsonInput, jqExpr, ['--raw-output'])
but it's "sticky", once applied it somehow stays there. so calling next time with
jq.promised.raw(jsonInput, jqExpr)
will still print row output.
example
window.jq.raw('{"a":"b\\nc"}','.a', [])
""b\nc""
window.jq.raw('{"a":"b\\nc"}','.a', ["--raw-output"])
"b
c"
window.jq.raw('{"a":"b\\nc"}','.a', [])
"b
from jq-web.
Related Issues (20)
- Sync function HOT 5
- jq version? HOT 2
- Cannot access full jq error details HOT 3
- If invalid JSON is passed to jq.promised.raw all future runs an empty string HOT 3
- jq flags `-r` effect seems can't cancel between calls ? HOT 11
- jq-web module suddenly stops working HOT 1
- todate doesn't work in chrome extension. HOT 5
- Unclosed streams caused FS error after calling jq.json 2048 times. HOT 4
- v0.5.1 fails on any JQ expression containing "%" operator HOT 2
- How to write to pathes? Missing documentation
- Library uses very large amounts of storage HOT 1
- Include TypeScript types HOT 1
- Failure to include jq files HOT 1
- Error message gets cut off when parsing a malformed date
- Project dead? HOT 1
- Upgrade path for jq 1.7 HOT 3
- Intermittent `<generic error, no stack>` exception using jq.promised.json
- `Unexpected end of JSON input` from `jq.promised.json` if no result set produced
- jq-web no longer builds with modern emscripten. HOT 3
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-web.