1- Optimize for what will likely be approved for sale in the app store
2- Pick a problem to solve that isn’t part of the OS’ built-in capabilities
3- Have an exit strategy for when #’s 1 & 2 change without notice
Must watch: El Camino Del Ray trail hike video.
Working with large JSON output can be a pill, especially when the server strips white-space or makes no effort at formatting the response for human-readability.
Having previously looked for a solution to make this easy, and not finding the right Google-majik to find it, I came across this article that talks about BBEdit’s Unix filtering abilities: BBEdit: Its Unix Support Doesn’t Suck Either, Part 2
I created this Python script that applies JSON pretty-print to text selected in the editor window:
#!/usr/local/bin/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)
Voila! Human-readable JSON.
UPDATE: If you are using BBEdit 10…
[NOTE: Also works on TextWrangler, the free, light version of BBEdit.]
See also: