-5
"messages": [
{
"text": "testing",
"ts": "1479967441.000004",
"user": "ray",
"type": "message",
"bot_id": "B379PT5AT"
},
{
"text": "SWAT start",
"type": "message",
"user": "john",
"ts": "1479967379.000003"
},
{
"text": "SWAT close",
"type": "message",
"user": "ray",
"ts": "1479967379.000003"
},
另一個參數添加到JSON文件我想補充的另一個參數
"messages": [
{
"text": "testing",
"ts": "1479967441.000004",
"user": "ray",
"type": "message",
"bot_id": "B379PT5AT"
"icon": "URL...."
},
{
"text": "SWAT start",
"type": "message",
"user": "john",
"ts": "1479967379.000003"
"icon": "URL...."
},
{
"text": "SWAT close",
"type": "message",
"user": "ray",
"ts": "1479967379.000003"
"icon": "URL...."
},
代碼:
import simplejson
with open ('automation.json')as json_data:
data = simplejson.loads(json_data)
for r in data['messages']:
key = messages['icon']
messages["icon"] = ("testing")
outdata = simplejson.dumps(data)
這個圖標字段對每個對象都是一樣的嗎?如果沒有,那麼你會從哪裏得到這些信息? –
到目前爲止您嘗試過什麼? –
我得到了一個json文件 我想運行一個python腳本,以便我可以進行上述更改 –