Giter VIP home page Giter VIP logo

Comments (8)

stedolan avatar stedolan commented on July 24, 2024 1

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.

johan avatar johan commented on July 24, 2024

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.

nicowilliams avatar nicowilliams commented on July 24, 2024

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.

stedolan avatar stedolan commented on July 24, 2024

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.

nicowilliams avatar nicowilliams commented on July 24, 2024

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.

johan avatar johan commented on July 24, 2024

Command-line-flag-invoked lenient parsing sounds good; the json spec is strict about what is legal for a reason.

from jq.

espaciomore avatar espaciomore commented on July 24, 2024

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.

nicowilliams avatar nicowilliams commented on July 24, 2024

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)

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.