2017-08-09 20 views
0

ARC:爲什麼高級REST客戶端返回的json與Python中的Requests模塊返回的json不同?

https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo?hl=en-US

我在一個以.json文件保存返回的JSON和使用將它變成一個熊貓數據幀:

temp_json = pd.read_json('TempJson.json', orient='columns') 

這個偉大的工程。 但我使用的請求模塊在Python 2.7.13,具體有:

myResponse = requests.post(url, json= payload, headers = headers) 
jData = json.loads(myResponse.content) 

和1)的JSON結構比temp_json非常不同和2)它完全沉船我的代碼。任何想法爲什麼?從temp_json

段:從蟒JSON

{ 
    "expand": "schema,names", 
    "startAt": 0, 
"maxResults": 250, 
    "total": 3, 
    "issues": [ 
{ 
    "expand": "operations,editmeta,changelog,transitions,renderedFields", 
    "id": "1954523", 
    "key": "SPGC-14075", 
    "fields": {"summary": "QA: Build concentration support into CDC automation", 
    "issuetype": { 
     "self": "https://itec-jira.fmr.com/rest/api/2/issuetype/20", 
     "id": "20", 
     "description": "Default sub-task", 
     "iconUrl": "https://itec- 
jira.fmr.com/images/icons/issuetypes/subtask_alternate.png", 
     "name": "Sub task", 
     "subtask": true 

樣品:

{ 
    "issues": [ 
{ 
    "key": "SPGC-25646", 
    "fields": { 
    "status": { 
     "statusCategory": { 
     "name": "To Do", 
     "self": "https://itec-jira.fmr.com/rest/api/2/statuscategory/2", 
     "id": 2, 
     "key": "new", 
     "colorName": "blue-gray" 
     },..... 
+1

請顯示你得到的兩個不同的json。 – fazega

+0

我發佈了片段。 – jenkelblankel

+0

@jenkelblankel:你的片段不會顯示任何差異;字典可能是平等的,但只是按不同的順序列出它們的鍵。 – jwodder

回答

0

json.loads將創建被散列,以便內容將在加擾的順序Python字典。檢查json.loads是否爲請求和臨時文件返回相同的字典。如果它們不同,那麼數據是不同的。您可以使用漂亮的打印庫來幫助您調試深層嵌套的json。