【发布时间】:2020-03-11 20:34:04
【问题描述】:
edit a JSON file in Robot Framework
假设上面有同样的问题,但如果我需要添加多个对象,它应该作为变量传递。我们该怎么做?
json objects(key value pair)
{
"drive": 1,
"case_ids": [1419]
}
*** Settings ***
Documentation Library with keywords
Library Collections
Library DateTime
Library OperatingSystem
Library JSONLibrary
Robot file
*** Keywords ***
################################## New Functions Introduced #########################################
Add KeyValue To Json
[Arguments] ${config_file} ${key} ${value} ${address}=$
${json_obj}= Load JSON From File ${config_file}
${object_to_add}= Create Dictionary ${key}=${value}
${json_obj}= Add Object To Json ${json_obj} ${address} ${object_to_add}
[return] ${json_obj}
我相信上次我检查它时我们无法为单个变量设置键和值。
任何想法都将不胜感激。
【问题讨论】:
标签: json robotframework