News for hackers. Stuff that matters.
Re:Parsing JSON is a Minefield by arghwhat on Monday April 23, 2018 @05:17AM (#16901805)
Why in the world would I write a parser in bash or awk, regardless of the format? I certainly have better things to do. It doesn't matter how sensible a format is, those tools are simply not appropriate to write a parser in.

I have, however, written a JSON parser before at a previous company in C++ (they didn't want to pull in a library). It wasn't particularly hard.

And yes, like any other parser, it accepted additional non-JSON constructs. This was simply because it was take additional work to error out on those constructs, which would be a waste of time.

Re:Parsing JSON is a Minefield by Annatar on Monday April 23, 2018 @07:32AM (#16902421)
Why in the world would I have to use JavaScript or any object oriented programming language just because the application is poorly thought out and emits JSON? I certainly have better things to do.

It doesn't matter how sensible a format is, those tools are simply not appropriate to write a parser in.

AWK is a language designed for data parsing and processing. That is what it is designed to do.

How did you solve the parsing of arbitrarily nested structures?

Re:Parsing JSON is a Minefield by jhomedall on Monday April 23, 2018 @09:00AM (#16902990)
> How did you solve the parsing of arbitrarily nested structures?

Write a recursive descent parser, or use a parser generator.

Or, more realistically, use one of the many libraries available for parsing it (pretty much every language has one at this point).

Re:Parsing JSON is a Minefield by mikerybka on Monday April 23, 2018 @07:48PM (#16908515)
Re:Parsing JSON is a Minefield by rarepostinlurkr on Tuesday April 24, 2018 @01:07AM (#16909989)
Json is clearly data.

If awk cannot parse it, perhaps it’s a shortcoming of awk? =)

Re:Parsing JSON is a Minefield by Annatar on Tuesday April 24, 2018 @02:28AM (#16910373)
It’s not an AWK limitation; recursive descent parsers are non-trivial to implement and tricky to get right.