Skip to main content

Posts

Showing posts from January, 2018

How to format huge Json files

Recently I had to deal with some huge JSON backup files and needed to do a simple text search. But the JSON file is compact and so huge like 5Mb. None of my text editors could handle that size of a compact JSON file. The thing is when the JSON is in a compact, it's just one line. So when I open it up with a text editor or an IDE, it just crashes. It can't handle that much of a lengthy line. I could run a grep command in the command line but since it is just a single line, its not really useful to know the line number. The trick is to format the JSON file with tabbed indentation, but online Json formatters weren't good enough for this task. same as the text editor it just crashes. Or they don't really allow you to format huge JSON files. The answer The answer is Python! Python comes really handy at this work. Python comes with built-in JSON manipulation libraries, and you can run a python function in the command line even if you don't know how to code