Created
March 15, 2012 14:28
-
-
Save jabley/2044466 to your computer and use it in GitHub Desktop.
How to pretty print a large json document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:cp /Users/jabley/.m2/repository/com/google/code/gson/gson/2.1/gson-2.1.jar | |
import java.io.{OutputStreamWriter, FileOutputStream, FileReader} | |
import com.google.gson.{GsonBuilder, JsonParser} | |
val gson = new GsonBuilder().setPrettyPrinting().create() | |
val json = new JsonParser().parse(new FileReader("get-menu-and-start-order.json")) | |
val fos = new FileOutputStream("get-menu-and-start-order.pretty.json") | |
val writer = new OutputStreamWriter(fos) | |
gson.toJson(json, writer) | |
writer.flush() | |
fos.getFD().sync() | |
writer.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
online tools didn't like the size of the document that I'm playing with. I can't say I care for it much myself!