的响应: 的
[
{"msisdn":"85237009372","name":"Vicky","carrier":"AIRTEL"},
{"msisdn":"85237009373","name":"Vicky1","carrier":"AIRTEL"}
]
我想从响应中提取所有名称并将其分配给数组/列表?
的代码: 的
import groovy.json.JsonSlurper
// Retrieve valid mptu Amounts from GET mptu-amounts response
context.responseContent = context.testCase.getTestStepByName("xxxx").getPropertyValue("r_responseContent")
try
{
responseContentParsed = new JsonSlurper().parseText( context.responseContent )
context.mptuValidAlias = responseContentParsed.name[0]
log.info(context.mptuValidAlias)
}
它正在检索第一行,名称(即)vicky ..我想提取所有行的名称并将其分配给列表..如何做到这一点?
答案 0 :(得分:1)
更改此行:
context.mptuValidAlias = responseContentParsed.name[0]
到此:
context.mptuValidAlias = responseContentParsed.name