Conversation

Is there a fast way to just check a JSON file for syntactic correctness? I have ~13K JSON files I want to cat into jq and it keeps breaking in the middle when it hits a broken file...
6
24
This Tweet was deleted by the Tweet author. Learn more
FWIW it's not too bad with parallel and jq, but I continue to believe that it could be a lot faster if it weren't trying to construct the objects in memory etc.: ls *.json | parallel jq '<' {} '&>' /dev/null '||' echo {} real 0m21.016s user 6m20.112s sys 0m32.337s
2
1
yajl has a json_verify utility. It should be a lot faster since it's a performance-oriented streaming library. It also has json_reformat which you can use to either beautify or minimize json. There are faster library implementations but it's nice having those utilities available.
2
6
I only know about the yajl utilities because at one point I did json<tab> to see if I already had a tool for it and then used what I already had installed. Same reason that I use libxml2 for verification and minification of xml even though I think libxml2 is a terrible library.
1
1
I have yajl since i3-wm depends on it. Choosing json handling tools based on my choice of window manager is clearly the only logical approach. Can see we use it in github.com/GrapheneOS/gra among other places. Real thought went into choosing tools for CSS, HTML, JS, etc. though.
Who can reply?
People @moyix mentioned can reply