Robotframework 使用robot框架读取json文件时遇到问题
我正在尝试使用robot框架和Httplibrary解析json文件,但在解析过程中,我遇到了一个问题。请在下面的输出部分查找更多详细信息,并请让我知道可能的解决方案 输入文件以读取sample.jsonRobotframework 使用robot框架读取json文件时遇到问题,robotframework,Robotframework,我正在尝试使用robot框架和Httplibrary解析json文件,但在解析过程中,我遇到了一个问题。请在下面的输出部分查找更多详细信息,并请让我知道可能的解决方案 输入文件以读取sample.json { "age":100, "name":"mkyong.com", "messages":["msg 1","msg 2","msg 3"] } 机器人框架代码 *** Settings *** Documentation Te
{
"age":100,
"name":"mkyong.com",
"messages":["msg 1","msg 2","msg 3"]
}
机器人框架代码
*** Settings ***
Documentation Test our very first REST API
Library HttpLibrary.HTTP
Library OperatingSystem
*** Test Cases ***
Create Question Should Return Success
Created Question Details Should Be Correct
*** Keywords ***
Created Question Details Should Be Correct
${expectation} = Parse Json From File
Log ${expectation}
Parse Json From File
${file} = Get File sample.json
${json} = Parse Json ${file}
[Return] ${json}
但在解析json文件后获得以下输出:
{
u'age':100,
u'name':u'mkyong.com',
u'messages':[u'msg 1',u'msg 2',u'msg 3']
}
关键字应该返回一个数据结构,这意味着它的行为与它应该的完全一样
尝试检索您的一些值:
Parse Json From File
${file} = Get File sample.json
${json} = Parse Json ${file}
Log Get Json Value ${json} /age
Log Get Json Value ${json} /name
Log Get Json Value ${json} /messages
[Return] ${json}
关键字应该返回一个数据结构,这意味着它的行为与它应该的完全一样
尝试检索您的一些值:
Parse Json From File
${file} = Get File sample.json
${json} = Parse Json ${file}
Log Get Json Value ${json} /age
Log Get Json Value ${json} /name
Log Get Json Value ${json} /messages
[Return] ${json}