Forum Discussion

majji's avatar
majji
Occasional Visitor
8 years ago

getting java.lang.classcastexception at groovy step in Ready API

I am getting java.lang.classcastexception while running the groovy step in Ready API tool

 

Sample Code:

1. Parsing the soapui JSON response

2. Reading node values from the hierarchy by running the loop

   def PN=jsonresponse.result.hr1[1].hr2[1].hr

  for (i=0;i<=PN.size()-1;i++{

    if (PN[i].containsKey("name")){

     log.info PN[i].getAt("name")

}

}

3. while iterating, some times,for first iteration it is executing and for remaining loops it is giving classcastexception at the step " if (PN[i].containsKey("name")){"

 

Most of the times script giving error without running single iteration.

 

Please help me what could be the issue in this code?