fiatjaf / jq-web Goto Github PK
View Code? Open in Web Editor NEWjq in the browser with emscripten.
License: Other
jq in the browser with emscripten.
License: Other
Hello-
I'm trying to use this in my Vue.js app, but when I import like:
import jq from 'jq-web';
I get this error:
ERROR Failed to compile with 1 errors
This dependency was not found:
* fs in ./node_modules/jq-web/jq.min.js
To install it, you can run: npm install --save fs
I think this is because fs
is not available in a browser window. I already have fs
in my package.json
file and saved to node_modules
.
Should I be doing something else instead? The same thing happens if I use require
.
Hello, I want to use jq-web
with my own .jq
files where I have defined functions. Is this possible? I have tried using:
include "migrations" {search: "$ORIGIN/../../src/migrate/internal"}; [usage of functions inside .jq]
But it fails to find the files I need.
.[] | .Title
and pass data []
to it, no result set is producedUnexpected end of JSON input
error because it's called as JSON.parse("")
Hey @fiatjaf can we assume this project is dead?
...or is it just stable because jq releases are that old?
Hello!
I'm using the jq-web module to validate some jq expressions on my NodeJS application. Application was working as expected for a few days on K8s cluster and I validated ~1000 expressions. Then, out of nowhere, this happened.
There is an error in expression: ".IG_PKT_DROP__NO_FLOW > 0". Message: Error\n at Object.ensureErrnoError (/usr/src/app/node_modules/jq-web/jq.asm.bundle.min.js:1:1722236)\n at Object.staticInit (/usr/src/app/node_modules/jq-web/jq.asm.bundle.min.js:1:1722445)\n at /usr/src/app/node_modules/jq-web/jq.asm.bundle.min.js:1:1734039\n at Object. (/usr/src/app/node_modules/jq-web/jq.asm.bundle.min.js:1:1751789)\n at Module._compile (internal/modules/cjs/loader.js:1147:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)\n at Module.load (internal/modules/cjs/loader.js:996:32)\n at Function.Module._load (internal/modules/cjs/loader.js:896:14)\n at Module.require (internal/modules/cjs/loader.js:1036:19)\n at require (internal/modules/cjs/helpers.js:72:18)\n at Object. (/usr/src/app/jq/jq-validator.js:3:12)\n at Module._compile (internal/modules/cjs/loader.js:1147:30)\n at`` Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)\n at Module.load (internal/modules/cjs/loader.js:996:32)\n at Function.Module._load (internal/modules/cjs/loader.js:896:14)\n at Module.require (internal/modules/cjs/loader.js:1036:19)\n at require (internal/modules/cjs/helpers.js:72:18)\n at Object. (/usr/src/app/service/AggregatingAlertRuleService.js:10:21)\n at Module._compile (internal/modules/cjs/loader.js:1147:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)\n at Module.load (internal/modules/cjs/loader.js:996:32)\n at Function.Module._load (internal/modules/cjs/loader.js:896:14)
const validate = (expression, example, skipSemantic=false) => {
let result;
try {
result = jq.json(example, expression);
if (result === null) {
return new JqInvalidResult(expression, "Expression returned no result.")
}
} catch (e) {
return new JqSyntaxErrorResult(expression, e);
}
//other logic
}
Can you help me? I tried to go through the source code using the lines:offsets but it is all minified js code.
Since I don't know much about the original jq source code or how emscripten works, I'm asking for help about these issues at https://groups.google.com/forum/#!topic/emscripten-discuss/h09tleb6YX8
If anyone seeing this has a solution or a clue it will be highly appreciated.
Hello,
I recently took a look at this library and it appears that the error details are stripped a bit before being passed to the Promise.reject
?
The error I get is a string of Error: 1 compile error
when the error I want is the verbose error that jq
would normally provide:
jq: error: syntax error, unexpected '$', expecting IDENT or __loc__ (Unix shell quoting issues?) at <top-level>, line 1:
$$
jq: 1 compile error
I can see that the full error is actually returned by the WASM:
But it appears its stripped in the source maybe here?:
Line 30 in a9b0a2d
With the error being stripped down it makes it pretty painful to debug issues with the JQ syntax. In my specific case users are providing them so I'd like to give somewhat helpful feedback about what they can change instead of a vague compile error
string.
I think fixing this should be easy? Just don't split on the :
? Let me know if I'm reading this correctly.
jq.json({},'now|todate')
This will throw exception "jq: error (at :0): strftime/1 requires parsed datetime inputs"
For example, 1 % 1
.
Probably, this is caused by Emscripten update because %
is processed without any problems by jq-web v0.5.0.
jq 1.7 has now been released.
Is there an upgrade path to getting jq-web using this new jq version?
I can't quite tell, but it looks like jq-web is using jq 1.5?
Two changes have happened:
MODULARIZE_INSTANCE
is removed.Hi,
would be possible to add also the options via the jq function like jq(, , )?
we will need it for example for the option "-r"
Thanks! :)
PS: here is what we are building with your library https://github.com/zalando-incubator/bro-q
Sorry if it's already in the repo/release info somewhere, but could you tell me which version of jq the current release uses?
Thanks.
<generic error, no stack>
exception thrown when using jq.promised.json
jq.promised.json
When importing jq-web
in a TypeScript project I get this error, which I then have to ignore:
Could not find a declaration file for module 'jq-web'. ./node_modules/jq-web/jq.asm.bundle.min.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/jq-web` if it exists or add a new declaration (.d.ts) file containing `declare module 'jq-web';`ts(7016)
Is it possible to add some basic types to this package?
Due to a totally unexpected issue with process.platform
being reported as nonexistent in the instantiation of emscripten's NODEFS, an error is thrown when jq-web
is run on Node.js.
I imagine that an easy solution (already tried by me with manual compiled code editing) would be to not instantiate NODEFS in any way, but perhaps fixing the process.platform
would be better.
I'm asking for help on this topic at https://groups.google.com/forum/#!topic/emscripten-discuss/Ikl3qxPoFAk
If anyone seeing this has any solution or clue to a solution it will be highly appreciated.
Returning {} when .mem/.wasm are not loaded yet is good, but it'd be even better to have a sync call. (One that would block until the loading finished and maybe fail after a timeout)
Describe the bug
Error message gets cut off when applying fromdate
to an empty string
To Reproduce
"" | fromdate
.%SZ"
.The sandbox: https://codesandbox.io/s/exciting-curie-k6yccy?file=/src/index.js
Expected behavior
The error object should have a message describing the error, for example: Date "" does not match format "%Y-%m-%dT%H:%M:%SZ"
Environment
Google Chrome Version 100.0.4896.127 (Official Build) (x86_64)
jq-web v0.5.1
I've got FS error after 2048 times calling jq.json.
I debugged and found unclosed streams in FS.streams caused by https://github.com/fiatjaf/jq-web/blob/master/post.js#L20.
Below code can show the error.
jq.onInitialized.addListener(()=>{
for (var i =0;i<4098;i++) {
console.log(jq.json({ok:i},'.'));
}
console.log('ok')
})
You'll get
...
{ ok: 2046 }
Error: FS error
Error: FS error
..../jq.asm.bundle1.js:122
throw ex
^
Error: abort(Error: FS error). Build with -s ASSERTIONS=1 for more info.
version: release-0.5.1 jq.wasm.js
run in chrome F12.
// ------ worked well
> jq.raw('{"a":"hello"}', '.a')
< ""hello""
> jq.raw('{"a":"hello"}', '.a', ['-c'])
< ""hello""
// ------ once call with `-r`,
> jq.raw('{"a":"hello"}', '.a', ['-r'])
< "hello"
// ------ somethings err? following call can't cancel `-r` flag
> jq.raw('{"a":"hello"}', '.a')
< "hello"
> jq.raw('{"a":"hello"}', '.a', ['-c'])
< "hello"
then refresh page,
and worked well again.
When using jq.promised.raw
, if you pass an invalid <json-string>
as input then all future calls to jq.promised.raw
will return an empty string ""
.
Example:
// Pass invalid JSON in
await jq.promised.raw('{#@#}', '.');
// Result of the above is an empty string still.
// Pass in valid JSON
await jq.promised.raw('{"test":"test"}', '.');
// Result of the above is an empty string still.
This bug tripped me up but I figured out what causes it, let me know if you need more reproduction information.
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.