Live data from Hacker News

Ask HN: How do you view large JSON files?

news.ycombinator.com

31–40 of 60 posts

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

#32
Chrome console allows you to inspect an object and expand on the properties visually.

For the most common cases, I just copy and paste the string into the chrome console if I need to inspect some random JSON file really quick.

If it is too big to copy and paste, pipe it into a html file as a global variable and view the object in the console.

You can also just open a node repl and load the JSON into memory. node lets you auto complete property names by pressing tab, this is great for inspecting some unknown object.

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

#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 browsing activity, 2. Slightly extra battery life when just browsing and not developing stuff.

Disadvantage: You need to keep the network tab ready, otherwise you will have to reload the entire page with the network tab open.

EDIT:

My apologies if it wasn't clear. I was talking about the "Developer Tools" option in Chrome, in which there is a "Network" tab. It is available in "Chrome Menu" > "More Tools" > "Developer Tools". Alternatively you can hit Command + Option + I in mac, or some equivalent in Linux / Windows to get there.

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

#34

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.

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

#35
>but it freezes on files larger than 1 MB

That's a pretty large bug. Considering what JSON is supposed to be used for, passing data between two programs/processes, files larger than 1 MB should have been accounted for.

Does it freeze then crash, freeze until the OS takes care of it, or freeze temporarily then resume?

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

#36

The Python REPL and the JSON lib. Probably not the most efficient if you're starting out but if you're familiar with Python it can be quite effective.

This. I use the Ruby REPL, but same principle.

You have to be a little careful about not accidentally printing out the whole thing to stdout, but after its loaded into memory you can check keys at a given level, drill into the substructure, etc.

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

#40

>but it freezes on files larger than 1 MB That's a pretty large bug. Considering what JSON is supposed to be used for, passing data between two programs/processes, files larger than 1 MB should have been accounted for. Does it freeze then crash, freeze until the OS takes care of it, or freeze temporarily then resume?

It freezes temporarily then resumes after few minutes.
Post reply on HN