On calling a restful service with a JSON response get below class cast exception on processing JSON response
Caused by: java.lang.ClassCastException: net.minidev.json.JSONArray cannot be cast to java.lang.String
at org.xframium.utility.WebServiceClientUtil.processResult(WebServiceClientUtil.java:544)
at org.xframium.utility.WebServiceClientUtil.callWebService(WebServiceClientUtil.java:83)
... 20 more
Below is the sample test against which the error is happening:
If the below code is type casted then the error goes off
String value = ctx.read( param.path );
contextMap.put( param.name, value );
Changing it to below code has resolved the issue:
JSONArray value = (JSONArray)ctx.read( param.path );
contextMap.put( param.name, value.toJSONString() );
On calling a restful service with a JSON response get below class cast exception on processing JSON response
Caused by: java.lang.ClassCastException: net.minidev.json.JSONArray cannot be cast to java.lang.String at org.xframium.utility.WebServiceClientUtil.processResult(WebServiceClientUtil.java:544) at org.xframium.utility.WebServiceClientUtil.callWebService(WebServiceClientUtil.java:83) ... 20 more
Below is the sample test against which the error is happening:
If the below code is type casted then the error goes off
String value = ctx.read( param.path ); contextMap.put( param.name, value );
Changing it to below code has resolved the issue:
JSONArray value = (JSONArray)ctx.read( param.path ); contextMap.put( param.name, value.toJSONString() );