pretty print json in console

Java
new JSONObject(json).toString(2) 
Source

Also in Java: