我希望找到某種方式在JSON捲曲輸出的漂亮打印。 我寫了簡短的Python腳本用於此目的,但它不會與管 工作還我不想使用子進程並從中捲曲運行:如何解析JSON在bash或捲曲輸出傳遞給python腳本
所以Python:
#!/usr/bin/python
import simplejson
from pprint import pprint
import sys
print pprint(simplejson.loads(sys.argv[1]))
和JSON信息是:
{"response": {"utilization": {"eic": [{"date": "2012.03.06", "usage": []}, {"date": "2012.03.07", "usage": [{"srvCode": "SVC302", "upload": 267547188, "api-calls": {"fileGetInfo": 30, "getUserStorageQuota": 0, "setUserStorageQuota": 0, "fileUploadFlashInit": 31, "getAPISessionUser": 0, "setFileAccessControl": 0, "fileGetPreviewUrl": 0, "fileStartMultipartUpload": 0, "getServiceQuota": 0, "fileGetPreviewUrlsForBunch": 10, "xcodingGetStreamUrl": 0, "getSessionTimeLimit": 0, "fileGetCoversUrlsForBunch": 27, "makePreviews": 0, "setServiceQuota": 0, "getAPISessionTrusted": 3, "getFileAccessControl": 0, "xcodingGetFormats": 0, "getQuotaNotificationEmail": 0, "fileGetDownloadUrl": 0, "xcodingGetStreamInfo": 0, "fileUploadDone": 30, "getLocalServiceUtilization": 9, "getServiceUtilization": 0, "fileDelete": 19, "setSessionTimeLimit": 0, "fileGetMultipartUploadUrl": 0, "fileUploadInit": 0, "extractFileMetadata": 30, "setQuotaNotificationEmail": 0}, "average-storage": 3801210959.4961309, "download": 0, "transcoding": 0}]}]}}}
謝謝你們。我試圖找到這兩種解決方案。他們都很好。 – kurd 2012-03-07 13:04:12