0
我在轉換JSON成需要的格式問題的任何幫助,將不勝感激希望有一個可以幫助轉換JSON中必需的JSON甲酸
這裏是我生的JSON結果:
//for Time being I have given a single object here, in the same way, I would get 2 more objects in the same JSON response
OrderedDict([(u'totalSize', 3), (u'done', True), (u'records',
[OrderedDict([(u'attributes', OrderedDict([(u'type', u'Site'),
(u'url', u'/services/data/v29.0/sobjects/Site/0DM30000000CaYgGAK')])),
(u'Name', u'Renewals_Community1'), (u'DailyBandwidthLimit', 40960),
(u'DailyBandwidthUsed', 0.0), (u'DailyRequestTimeLimit', 3600),
(u'DailyRequestTimeUsed', 0.0), (u'MonthlyPageViewsEntitlement', 0)]),
必需的JSON甲:
{
"DailyBandwidthLimit":
{
"Max"://here my own value which is standard
"Remaining":"40960"//(u'DailyBandwidthLimit', 40960),
}
}
使用多種方法來轉換:
寫一個for循環僅打印所需的數據
for i in rs['records']:
printi['DailyBandwidthLimit']
///because of less space I am not placing all the code
在這裏我能夠得到所需的字段,但無法形成JSON嘗試了不同的選項,如打印數據保存到文件的使用JSON.loads文件json.dumps &再次讀取數據似乎沒有任何工作以及
Finally
data[]
data['Max'] = 8
data['Remainig']= d
data['DailyBandwidthLimit'] = [""]
json_data = json.dumps(data)
print json_data
它的到來在一定程度上,但我無法作出所需的JSON
在此先感謝
感謝它的工作 –
歡迎您 – paperazzo79