我是新來的python,我需要解析一個JSON文件,它有HTTP
響應標題,我需要找到一組特定的標題類型,使用或不。我JSON
文件將是這樣的:如何解析Json文件並搜索特定的關鍵字集?
"2236": {
"status": "200 OK",
"x-request-id": "13e98a1c93205a532810b2d34c92a04d",
"x-powered-by": "Phusion Passenger 4.0.21",
"transfer-encoding": "chunked",
"set-cookie": "ip_country=IN; path=/; expires=Fri, 25-May-2035 06:54:09 GMT",
"expires": "Thu, 28 May 2015 06:54:10 GMT",
"vary": "Accept-Encoding",
"connection": "keep-alive",
"server": "nginx/1.2.1",
"x-runtime": "0.780037",
"etag": "\"0ac30791df0dae1e4723d5360e82cee4\"",
"x-ua-compatible": "IE=Edge,chrome=1",
"cache-control": "max-age=259200, public",
"date": "Mon, 25 May 2015 06:54:10 GMT",
"content-type": "text/html; charset=utf-8",
"x-rack-cache": "miss"
},
"1681": {
"content-length": "56",
"accept-ranges": "bytes",
"vary": "Accept-Encoding,User-Agent",
"server": "PonyCakesv1.33.7",
"last-modified": "Fri, 22 May 2015 19:29:33 GMT",
"etag": "\"1c2665-2eb4-516b0ae026140\"",
"location": "http://www.olark.com/",
"date": "Mon, 25 May 2015 06:55:02 GMT",
"x-frame-options": "SAMEORIGIN",
"content-type": "text/html; charset=utf-8"
}
的數字是ID和我需要找到每個IDS使用'content-type' & 'x-frame-options'
。
我的輸出結果有被喜歡:
2236,content-type
1681,content-type,x-frame-options
如何實現這一目標?
那你嘗試了嗎? –