Maintain Order in JSON Import
Sannyasin Brahmanathaswami
brahma at hindu.org
Wed Sep 14 22:13:50 EDT 2016
brahma at hindu.org> wrote:
"Actually if I just let the jsonExport and jsonImport do the work… it's valid json… except that what's on disk is all on a single line."
Python to the rescue: this works as a text filter in BBEdit
save to:
~/Library/Application Support/BBEdit/Text Filters/
#!/usr/bin/env python
import fileinput
import json
if __name__ == "__main__":
jsonStr = ''
for a_line in fileinput.input():
jsonStr = jsonStr + ' ' + a_line.strip()
jsonObj = json.loads(jsonStr)
print json.dumps(jsonObj, sort_keys=True, indent=2)
More information about the use-livecode
mailing list