首页 > 代码库 > [SoapUI] 在SoapUI script里获取Response(Json格式)某个节点值

[SoapUI] 在SoapUI script里获取Response(Json格式)某个节点值

import com.eviware.soapui.support.GroovyUtils
import com.eviware.soapui.support.JsonUtil
import com.jayway.jsonpath.*
import com.eviware.soapui.support.XmlHolder

String responseAPI = context.expand(‘${GetFundSizeValueScoreFromAPI#Response}‘)  //get response
def data = http://www.mamicode.com/JsonPath.read(responseAPI,‘$.data[0].effectiveDate‘)  // get data by Jpath>
or
def data = http://www.mamicode.com/JsonPath.read(responseAPI,‘$.data‘)
String effectiveDate = data.get(0).get("effectiveDate")
log.info effectiveDate

 

[SoapUI] 在SoapUI script里获取Response(Json格式)某个节点值