Giter Site home page Giter Site logo

Add jq options about jq-web HOT 6 OPEN

mrandi avatar mrandi commented on May 23, 2024
Add jq options

from jq-web.

Comments (6)

fiatjaf avatar fiatjaf commented on May 23, 2024 1

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.

fiatjaf avatar fiatjaf commented on May 23, 2024

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.

mrandi avatar mrandi commented on May 23, 2024

@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.

fiatjaf avatar fiatjaf commented on May 23, 2024

Have you tried this?

 function getJq(jsonInput, filter = '.') {
-    return jq(JSON.parse(jsonInput), filter);
+    return jq.raw(jsonInput, filter);
 }

from jq-web.

mrandi avatar mrandi commented on May 23, 2024

@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.

romaninozemtsev avatar romaninozemtsev commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.