Forum Discussion
No signature of method: groovy.json.JsonSlurper.parseText() is applicable for argument types: (com.eviware.soapui.impl.wsdl.submit.transports.http.SinglePartHttpResponse) values: [com.eviware.soapui.impl.wsdl.submit.transports.http.SinglePartHttpResponse@13ad1457] Possible solutions: parseText(java.lang.String), parse(java.io.Reader)
I tryed to execute your code But.
Im getting this error. Any idea?
This is the exact API.
https://a31k83hfp9.execute-api.us-east-1.amazonaws.com/dev/schools?filterParams=default
Hi,
It just looks like you didn't put in the correction I mentioned in my second post above.
Attached is a project with a working example.
- chathurad7 years agoContributor
Cool. It is working fine.
Could you please explaine me the code, "
.with { groovy.json.JsonOutput.toJson( it ) }
".
I cant understand what it does. Specialy "it".
- JHunt7 years agoCommunity Hero
Use JsonOutput like this:
import groovy.json.JsonOutput Map mySomething = ["abc": "def"] String j = JsonOutput.toJson( mySomething )
assert j == '{"abc":"def"}'As for with and it:
String x = "abc"
x.with {
assert it == "abc"
assert it == x;
assert it.is(x)
}So:
String unsorted = new groovy.json.JsonSlurper() // returns a JsonSlurper
.parseText(messageExchange.responseContent) // call parseText method on the JsonSlurper, returns a type of Map
."result" // call the getAt method on the Map, returns a ListArray in this case .with { groovy.json.JsonOutput.toJson( it ) } // calls toJson with the ListArray as argument, returns a String
// String is assigned to variable 'unsorted'Equivalent to doing this:
String unsorted = groovy.json.JsonOutput.toJson ( new groovy.json.JsonSlurper() .parseText(messageExchange.responseContent) ."result" )
Related Content
- 4 years ago
Recent Discussions
- 15 years ago