Live data from Hacker News

Ask HN: How do you view large JSON files?

news.ycombinator.com

51–60 of 60 posts

Re: Ask HN: How do you view large JSON files?

#51
post #33

I used to be a fan of JSONView or one of those chrome plugins / extensions. Then I realized that I can simply use the network tab to view the JSON data as it gets loaded. Here is how it works - keep the network tab ready. When you see the JSON data request, click on the request and hit the "Preview" tab. It gives you data in a collapse / expand format. Advantages: 1. There is one less plugin that scans all your brows…

Usually F12 opens these tools in most browsers (IE, Chrome, Firefox at least) on Linux and Windows, but I do not have a Mac to test Os X. Your tip also applies to Firefox, but I don't know about IE or Edge. :)

I've never really had to handle really large JSON files, as I'm not a big fan of those but for smaller files I tend to be lazy and paste it in jsonlint.com. It's usually just for reference or debugging purposes (like finding the name of a property or some strange value).

Re: Ask HN: How do you view large JSON files?

#52

Earlier quoted context omitted.

It's not nice to abuse innocent cats. python -mjson.tool If you're not using cat to concatenate things, the shell can probably handle the job.

People like cat because it allows notating the command closer to how they think. How can I pipe while putting the file first?

Well, just do it:

    

Re: Ask HN: How do you view large JSON files?

#54

If you're familiar with vim, you can do this cat unformatted.json | python -mjson.tool | vim - And then use vim's folding methods to navigate the file ( http://vim.wikia.com/wiki/Folding )

It's not nice to abuse innocent cats. python -mjson.tool If you're not using cat to concatenate things, the shell can probably handle the job.

What's the immediate advantage for me in using a less intuitive syntax? I understand cat is meant to concatenate files, so what?

Re: Ask HN: How do you view large JSON files?

#55
post #44

Earlier quoted context omitted.

Well-designed text formats too?

Not necessarily. (I'd actually argue "not at all.") Presumably you have a text format in the first place because you want your representation to be human-readable [with common tools like a text editor], and very likely human-writable as well. Those are the real constraints of a (useful) text format, and they tend to be in direct conflict with high-performance parsing, or partial parsing. For an arbitrary example, a b…

Indeed. Another example is that you could have a length field in a text format that precedes a string, so you can skip over it without parsing it. But humans will forget to update it, or update it incorrectly.

Re: Ask HN: How do you view large JSON files?

#56
There are few viewers/editors listed at http://softwarerecs.stackexchange.com/questions/18839/json-v...

JSONedit should work well with files up to few MBs, with larger files loading time may be not acceptable. Side note: for editors that generate structured view file size may be not precise metric - number of elements might work better.

Re: Ask HN: How do you view large JSON files?

#58
post #44

Earlier quoted context omitted.

Well-designed text formats too?

Not necessarily. (I'd actually argue "not at all.") Presumably you have a text format in the first place because you want your representation to be human-readable [with common tools like a text editor], and very likely human-writable as well. Those are the real constraints of a (useful) text format, and they tend to be in direct conflict with high-performance parsing, or partial parsing. For an arbitrary example, a b…

> Really, the true advantage of a binary format is you generally assume that nobody messed with the data behind your back

I would rephrase that a bit and say the true advantage is flexibility, as you're not subject to the constraints of textual data.

The integrity of the data is a separate matter, and should be carefully verified rather than trusted implicitly. A huge amount of security vulnerabilities, and program crashes in general, come from errantly assuming that user-supplied data is correct.

Re: Ask HN: How do you view large JSON files?

#59
Generally I'll copy it to the clipboard (usually `pbcopy < file.json`), fire up Chrome, Cmd+Alt+J, then paste into the console. Instant, attractive, collapsible rendering of the content. Usually when I do this I'm interested in performing some sort of transformation on the data, and this way I can prototype it without any further steps.
Post reply on HN