Skip to content

Instantly share code, notes, and snippets.

@auramo
Created October 23, 2013 08:50
Show Gist options
  • Save auramo/7114970 to your computer and use it in GitHub Desktop.
Save auramo/7114970 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import json
import fileinput
def compact(raw):
parsed = json.loads(raw)
compacted = json.dumps(parsed, separators=(',',':'))
return compacted
def read_from_input():
lines = []
for line in fileinput.input():
lines.append(line.rstrip('\n'))
return ''.join(lines)
raw = read_from_input()
compacted = compact(raw)
print compacted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment