robotframework - 如何将数据作为字典添加到 json 文件?
问题描述
我有一个 JSON 文件来使用它来调用 API。我想向它添加一些新数据
我尝试使用将对象添加到 JSONLibrary 的 JSON,但它没有按预期工作。这是 Json 文件。
{
"customer_name":"Nguyễn Lê Cường",
"sender":{
"fullname":"Nguyễn Lê Cường",
"phone":"0932028646",
"address":"234 Trương Minh Ký, Phường 1, Tân Bình, Hồ Chí Minh, Việt Nam",
"region_id":1455,
"district":"Quận Tân Bình",
"province":"Hồ Chí Minh",
"location":[
10.795365,
106.66720800000007
]
},
"group_id":23,
"service_id":1,
"fee_ship":0,
"service_package_type":"SGN-TRANS-2500",
"hub":"HCM",
"payment_type":3,
"note":"note for driver",
"truck_payload":2500,
"content":"Đơn hàng nguyên chuyến",
"order_time":"2019-08-15T09:24:55.192Z",
"stop_points":[
{
"fullname":"Nguyễn Lê Cường",
"phone":"0932028646",
"address":"234 Trương Minh Ký, Phường 1, Tân Bình, Hồ Chí Minh, Việt Nam",
"region_id":1455,
"district":"Quận Tân Bình",
"province":"Hồ Chí Minh",
"location":[
10.795365,
106.66720800000007
],
"sort":1,
"pick_items":{
"number_of_items":0,
"weight":0,
"cubic_volume":[
0,
0,
0
],
"items":[
]
},
"drop_items":{
"number_of_items":0,
"weight":0,
"cubic_volume":[
0,
0,
0
],
"items":[
]
},
"pick_papers":[
{
"code":"",
"name":"",
"description":"",
"type":""
}
],
"drop_papers":[
{
"code":"",
"name":"",
"description":"",
"type":""
}
],
"note":"this is the note",
"paper":"CTDK01 CTDK02",
"cod":0,
"address_detail":"Hẻm 35 Trương Minh Ký "
},
{
"fullname":"Nguyễn Lê Minh",
"phone":"0932228888",
"address":"146 Pasteur, Bến Nghé, Quận 1, Hồ Chí Minh, Việt Nam",
"region_id":1442,
"district":"Quận 1",
"province":"Hồ Chí Minh",
"location":[
10.775334,
106.70081000000005
],
"sort":2,
"pick_items":{
"number_of_items":0,
"weight":0,
"cubic_volume":[
0,
0,
0
],
"items":[
]
},
"drop_items":{
"number_of_items":0,
"weight":0,
"cubic_volume":[
0,
0,
0
],
"items":[
]
},
"pick_papers":[
{
"code":"",
"name":"",
"description":"",
"type":""
}
],
"drop_papers":[
{
"code":"",
"name":"",
"description":"",
"type":""
}
],
"note":"this is note 2",
"paper":"CTDK03",
"cod":0,
"address_detail":"146/55 Pasteur"
}
] }
这是我要添加到 {
"fullname":"Nguyễn Lê Minh", "phone":"0932228888", "address":"146 Pasteur, Bến Nghé, Quận 1, Hồ Chí Minh, Việt Nam" , "region_id":1442, "district":"Quận 1", "province":"Hồ Chi Minh", "location":[
10.775334, 106.70081000000005 ], "sort":2, "pick_items":{
"number_of_items" :0,“重量”:0,“立方体积”:[
0, 0, 0 ],“项目”:[
]
},
"drop_items":{
"number_of_items":0,
"weight":0,
"cubic_volume":[
0,
0,
0
],
"items":[
]
},
"pick_papers":[
{
"code":"",
"name":"",
"description":"",
"type":""
}
],
"drop_papers":[
{
"code":"",
"name":"",
"description":"",
"type":""
}
],
"note":"this is note 2",
"paper":"CTDK03",
"cod":0,
"address_detail":"146/55 Pasteur"
}
它是“stop_points”的一部分,我尝试将对象添加到 JSON,但它返回的不是 stop_points 的一部分
解决方案
推荐阅读
- python - Flask 1.1.x - 使用模板的基本路由问题
- python - 使用 pyenv-virtualenv 设置 virtualenv 时出现 ASCII 编解码器错误
- linux - 如何在sed中插入不间断的空间?
- firebase - firebase_database 错误
- css - 使用缓动功能暂停/恢复 CSS 动画
- java - 屏幕关闭/锁定后手机振动停止工作
- c# - C# - for 循环的问题。超出数组范围的索引 - 为什么程序不跳出 for 循环并继续
- python - asyncio:异常时停止协程
- php - 为什么从数据库表中提取的俄语文本和放入表中的信息会变成问号和奇怪的符号?
- scala - 在编译时验证 Scala 案例类