Skip to content

Instantly share code, notes, and snippets.

@tomhennigan
Created July 26, 2012 10:18
Show Gist options
  • Save tomhennigan/3181359 to your computer and use it in GitHub Desktop.
Save tomhennigan/3181359 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import simplejson
while True:
line = sys.stdin.readline()
if not line:
break
parts = line.split("\t")
formatted = []
for part in parts:
try:
f = simplejson.dumps(simplejson.loads(part), sort_keys = False, indent = 4)
except:
f = part
formatted.append(f.rstrip("\n"))
print "\t".join(formatted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment