Comments (8)
Yeah, I don't want jq to ever accept non-JSON by default, but a command-line argument to accept sorta-kinda-nearly-json would occasionally be handy.
from jq.
I made a stand-alone shell clean-up tool for anyone else with the same problem that can't wait for something like this, but it would be nice not to need it: https://gist.github.com/4323895
from jq.
FYI:
% node
> a = "\000"
'\u0000'
> JSON.stringify(a)
'"\\u0000"'
> JSON.parse(JSON.stringify(a))
'\u0000'
> JSON.parse('"\\u0000"')
'\u0000'
> JSON.parse('"\\000"')
... ^C
> JSON.parse('"\\007"')
... ^C
>
I also tried the Chrome console:
> JSON.parse('"\\u0000"')
""
> JSON.parse('"\\000"')
SyntaxError: Unexpected number
I think you might be confused. Near as I can tell ECMAscript accepts octal escapes (it does), but ECMAScript's JSON.parse() doesn't. Indeed, ECMAScript 6 (draft) doesn't allow octal escapes: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-15.12.1 .
from jq.
I don't think this is about octal escapes ever being valid JSON, or even accepted by any sane JSON parser.
Sadly, there is a certain amount of non-JSON around that people refer to as "json", which often happens to be valid ECMAScript that eval()s to something representable in JSON. jq doesn't (and won't) accept such nonsense by default, but it might be useful to have a --broken-json
argument that uses a different JSON parser which accepts some arbitrary collection of sorta-common almost-json syntaxes.
Not something I have time for at the moment, but might be worth implementing eventually.
from jq.
I don't think this is about octal escapes ever being valid JSON, or even accepted by any sane JSON parser.
Ah.
Sadly, there is a certain amount of non-JSON around that people refer to as "json", which often happens to be valid ECMAScript that eval()s to something representable in JSON. jq doesn't (and won't) accept such nonsense by default, but it might be useful to have a --broken-json argument that uses a different JSON parser which accepts some arbitrary collection of sorta-common almost-json syntaxes.
Yes, options for parsing "extensions" would be nice.
from jq.
Command-line-flag-invoked lenient parsing sounds good; the json spec is strict about what is legal for a reason.
from jq.
about the silent output ?.. I just want to see the following:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 762 100 762 0 0 12 0 0:01:03 0:01:00 0:00:03 180
and nothing more !
from jq.
IMO jq should have multiple parsers, or perhaps it should be pluggable as to parsers. That way jq could be made to parse dirty-JSON, JSONish, and even binary JSON formats. As for the default behavior, invalid values should not be parsed, and valid values should not be parsed differently -- specifically there should be no octal escape support in the jq JSON parser, as JSON does not include octal escapes.
from jq.
Related Issues (20)
- Null bytes are handled inconsistently HOT 5
- tonumber doesn't work on `true` or `false` HOT 4
- "color for object keys" from JQ_COLORS doesn't seem to be respected HOT 4
- `range/3` behaviour when $init and $upto arguments are not numbers HOT 4
- Regular expression alternation (|) used with quantifier (* or +) returns inconsistent results when first alternative is able to match an empty string HOT 3
- Create Multi Smaller Files From a Big Json File HOT 5
- Add the Symbolic Binding Operator ("as") to the operator priority table HOT 1
- Including and importing module with importing JSON crashes jq
- The code example for trim ltrim and rtrim from the manual do not work HOT 2
- Incorrect `Invalid path expression` in destructuring expressions
- 1.7.1 dumps core on Cygwin, trying to find the input filename to print an error message HOT 5
- jq --raw modes, --binary and newlines
- Request for snap maintenance HOT 11
- strptime month does not match input HOT 2
- Using unique or unique_by in a filter causes subsequent (after comma ,) filter inputs to be replaced with its output HOT 5
- Docker images lack `latest` tag HOT 2
- modulemeta failure when module location is found by "search"
- oss-fuzz/issues/detail?id=68056
- Unexpected env builtin behaviour HOT 5
- Undefined behaviour in use of <ctype.h> functions
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.