cyzyvos It would be cool if JSON responses were formatted (like in Firefox) instead of rendered as plain text. Plain text should remain as an option though. Sample JSON: https://www.reddit.com/r/all.json
jvacek This is one of the reasons I have to sometimes switch to Firefox for my day-to-day work. I can't seem to get the JSON formatter chrome extensions to work, or the user scripts via tampermonkey etc.
Vlad jvacek I agree 🙂 Can someone find a superfast and supersmall piece of JS code that formats even the biggest of JSON responses in a nice way?
jvacek Vlad I think this might actually be it, in the Firefox source code https://searchfox.org/mozilla-central/source/devtools/client/jsonview
jvacek I would love to also have the filtering functionality, plus header inspection if possible This might be a stretch but is it possible that Firefox' implementation is actually a JS script? it generates a full DOM and everything
Vlad jvacek I've tried built in JSON viewer from Firefox on https://raw.githubusercontent.com/json-iterator/test-data/master/large-file.json and it does not seem to work.
jvacek Vlad it has its limits 😉 I think it's safe to re-use those limits if Firefox deems them appropriate. It works well for "normal" workloads.
Vlad jvacek It shouldn't 🙂 Have you tried using extensions? This extension produces pretty output https://chrome.google.com/webstore/detail/json-lite/acacmjcicejlmjcheoklfdchempahoag This one is not as pretty but will work even with giant json files (like the one above). https://chrome.google.com/webstore/detail/ultra-fast-json-viewer/achlegaapdgcnnhfmliagapbampafine
jvacek The second one does not work for me in Orion. It pretty-prints the output, but doesn't do any collapsing or highlighting. Neither of them were able to load the large JSON file for me
jvacek ED: looks like the big file might work even with the firefox viewer maybe? Might also explain why the other ones don't format it
tiw Shouldn't just JSON.stringify() be a good baseline for json outputs, though? Highlighting and such can come later?
Vlad tiw Sounds like a good idea. Can you supply a pieace of code that would do that? (so it can be run on a .json page in console and produce meaningful output?)
tiw Something like document.body.firstChild.innerHTML = JSON.stringify(JSON.parse(document.body.firstChild.innerHTML), null, 4) probably suffices, at least to me.
Vlad tiw In the meantime consider making a bookmarklet out of it https://mrcoles.com/bookmarklet/ in addition this extension also works https://chrome.google.com/webstore/detail/ultra-fast-json-viewer/achlegaapdgcnnhfmliagapbampafine