Tag Archives: json

What is Wrong with JSON Viewer on Codeplex

JSON Viewer for Windows (hosted on Codeplex) is a great tool, I use it at least once a week. However it hasn’t been updated since 2011:
about-json-viewer

Here is the list of issues with version 1.2 of JSON Viewer.

1. When you open a large JSON file (more than 10 MB) the viewer freezes for 2-3 minutes, sometimes longer. You have to kill it with Task Manager.

2. When you edit JSON the cursor always jumps to the beginning of the file – very annoying. Making any changes to JSON is essentially impossible.

3. The URLs in JSON look like hyperlinks but clicking on them does nothing:
links-in-json-viewer

4. When you press Ctrl+V in the search field the text gets pasted to the JSON document instead, usually making it invalid!

Did I miss anything?

How to View Large JSON Files on Windows

Let’s say you need to view a huge (more than 1 GB) JSON file. Of course you are not going to view so much data, it’s humanly impossible. What you want to do is to get a general understanding of JSON structure.

I assume that JSON document is already properly formatted.

First of all we will copy first 10,000 lines to a new file. We will user PowerShell for that:

Get-Content large.json -TotalCount 10000 | Out-File truncated.json

Next, open truncated.json in Sublime Text Editor and scroll to the end:
sublime-truncated-json

The JSON is not valid right now. Let’s make it valid by closing all ‘[‘ and ‘{‘ brackets. Sublime Text has a great feature that highlights invalid JSON code:
sublime-invalid-json-highlighted

All you need to do is to try to add brackets alternating between ‘[‘ and ‘{‘ until you reach the first column:
sublime-valid-json

Now you can save the file and open it in JSON Viewer. Since the new file is small you should have no problems viewing it as tree:
json-viewer

By the way, I’m thinking of building a tool that would automate this process – leave a comment if you’re interested in learning more.

Viewing JSON

From time to time I need to examine data in JSON format. Now unformatted JSON is very hard to read, for example:

{"movies":[{"id":"770739679","title":"Captain America: The First Avenger","year":2011,"mpaa_rating":"PG-13","runtime":121,"critics_consensus":"With plenty of pulpy action, a pleasantly...","release_dates":{"theater":"2011-07-22"},"ratings":{"critics_rating":"Fresh","critics_score":71,"audience_score":96},"synopsis":"Captain America: The First Avenger will focus on the early days...","posters":{"thumbnail":"http://content9.flixster.com/movie/11/15/83/11158339_tmb.jpg","profile":"http://content9.flixster.com/movie/11/15/83/11158339_tmb.jpg","detailed":"http://content9.flixster.com/movie/11/15/83/11158339_tmb.jpg","original":"http://content9.flixster.com/movie/11/15/83/11158339_tmb.jpg"},"abridged_cast":[{"name":"Chris Evans","characters":["Captain America/Steve Rogers","Steve Rogers / Captain America","Steve Rogers/Captain America"]},{"name":"Hayley Atwell","characters":["Peggy Carter"]},{"name":"Sebastian Stan","characters":["Bucky Barnes","James Buchanan \"Bucky\" Barnes"]},{"name":"Tommy Lee Jones","characters":["Colonel Chester Phillips"]},{"name":"Hugo Weaving","characters":["Johann Schmidt/Red Skull","Johann Schmidt/The Red Skull","Red Skull"]}],"alternate_ids":{"imdb":"0458339"}}

I usually use JSON Viewer to format JSON:

{
    "movies": [
        {
            "id": "770739679",
            "title": "Captain America: The First Avenger",
            "year": 2011,
            "mpaa_rating": "PG-13",
            "runtime": 121,
            "critics_consensus": "With plenty of pulpy action...",
            "release_dates": {
                "theater": "2011-07-22"
            },
            "ratings": {
                "critics_rating": "Fresh",
                "critics_score": 71,
                "audience_score": 96
            },
            "synopsis": "Captain America: The First Avenger will focus...",
            "posters": {
                "thumbnail": "http://content9.flixster.com/movie/11/15/83/11158339_tmb.jpg",
                "profile": "http://content9.flixster.com/movie/11/15/83/11158339_tmb.jpg",
                "detailed": "http://content9.flixster.com/movie/11/15/83/11158339_tmb.jpg",
                "original": "http://content9.flixster.com/movie/11/15/83/11158339_tmb.jpg"
            },
            "abridged_cast": [
                {
                    "name": "Chris Evans",
                    "characters": [
                        "Captain America/Steve Rogers",
                        "Steve Rogers / Captain America",
                        "Steve Rogers/Captain America"
                    ]
                },
                {
                    "name": "Hayley Atwell",
                    "characters": [
                        "Peggy Carter"
                    ]
                },
                {
                    "name": "Sebastian Stan",
                    "characters": [
                        "Bucky Barnes",
                        "James Buchanan \"Bucky\" Barnes"
                    ]
                },
                {
                    "name": "Tommy Lee Jones",
                    "characters": [
                        "Colonel Chester Phillips"
                    ]
                },
                {
                    "name": "Hugo Weaving",
                    "characters": [
                        "Johann Schmidt/Red Skull",
                        "Johann Schmidt/The Red Skull",
                        "Red Skull"
                    ]
                }
            ],
            "alternate_ids": {
                "imdb": "0458339"
            }
        }
    ]
}

Much better isn't it?

JSON Viewer is great because it also shows JSON in a tree:
JSON Viewer

Now I can easily expand and collapse elements and quickly understand the structure of the data.

However there is one problem: JSON Viewer doesn't handle large files well. If I try to open 4 MB file it just freezes for few minutes and I have to kill it with Process Explorer.

Do you have the same problem too? How would you like to see the problem solved? Please answer as a comment below.