我有這個JSON轉儲時我只是寫成文件,該文件是沒有很好地縮進,而不是可讀性,以便使其更具可讀性我這樣做試圖縮進一個JSON轉儲,然後寫一個文件
with open(responseFile, 'w') as outfile:
outfile.write(dumps(loads(content), indent=4))
但現在我得到這個無效的\ escape:錯誤。有什麼建議麼 ?
例如內容:
{"devices":{"device":{"customAssetNumber":"","deviceName":"Shamik\'s iPhone","deviceOwner":"","deviceStatus":"Active","deviceType":"Smartphone","emailAddress":"[email protected]","imeiEsn":342342,"installedDate":"2014-03-04T09:14:58","lastReported":"2014-03-05T06:48:42","DeviceID":"ApplC39GMAR7DTD8","Status":"Enrolled","mailboxDeviceId":"","mailboxLastReported":"","mailboxManaged":"","manufacturer":"Apple","model":"iPhone 4S","osName":"iOS 7","osServicePack":"","ownership":"Not Defined","platformName":"iOS","sourceID":1,"udid":"","unifiedTravelerDeviceId":"","username":"sray","wifiMacAddress":""},"count":1,"pageNumber":1,"pageSize":1}}
「加載(內容)」是否獨立工作?聽起來你在這裏有無效的JSON。 –
它不工作。可以做些什麼來修復內容? – Shamik
修復內容,使其有效json –