开发的接口,欲哭无泪:

要取接口中,FID,Mac等的值,但是在数组中,field的数量是变化的,不能使用index获取,只能for 循环了。
比如拿身份证:

code:
${result_Jason} To Json ${result.content}
${tag_value} Get From Dictionary ${result_Jason} data
${tag_value} Get From Dictionary ${tag_value} sums
${b} Get Length ${tag_value}
${d} Set Variable 1
: FOR ${i} IN RANGE 0 ${b}
\ ${tag_type} Get From Dictionary ${tag_value[${i}]} field
\ ${c} Get From Dictionary ${tag_value[${i}]} value
\ ${d} Set Variable If '${tag_type}' == '身份证' ${c}
\ run keyword if '${tag_type}' == '身份证' exit for loop
Log ${d}
先解析Json,然后for 循环遍历 sums,
如果field 中的值等于身份证,则去value的值。
或者
${get_value} Set Variable 1
: FOR ${i} IN RANGE 0 ${b}
\ ${tag_type} Get From Dictionary ${tag_value[${i}]} field
\ ${get_value} = run keyword if '${tag_type}' == '身份证' Get From Dictionary ${tag_value[${i}]} value
\ run keyword if '${tag_type}' == '身份证' exit for loop
Log ${get_value}

网友评论