Forum Discussion

JoostDG's avatar
JoostDG
Frequent Contributor
7 years ago

JsonSlurper no longer available in 2.3.0 - Solution: JsonUtil.parseTrimmedText

Old piece of groovy code, that I used to get the count of number of JSON nodes:

 

import net.sf.json.groovy.JsonSlurper

 

def abc = context.expand(grab an array from request/response)
def abcArray = new JsonSlurper().parseText(abc).results
def x = abcArray.size()

--> x  would tell me the number of nodes

 

With 2.3.0 this ends up in "unable to resolve class net.sf.json.groovy.JsonSlurper" error.

 

Replaced now with:

import com.eviware.soapui.support.JsonUtil

def abc = context.expand(grab an array from request/response)

def abcArray = JsonUtil.parseTrimmedText(abc)

def x = abcArray.size()

 

... and providing me the same result! 

 

This change is due to :

https://support.smartbear.com/readyapi/docs/general-info/whats-new.html#readyapi

 

Changes in script methods. We updated a Java library that we use internally to work with data in the JSON format. The JSON type declared in it has been replaced with JsonNode. This caused changes to the methods listed below. You may need to change the script code if you use these methods in your Groovy scripts in ReadyAPI.

No RepliesBe the first to reply