cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert array to intger with groovy ?

SOLVED
Frequent Contributor

How to convert array to intger with groovy ?

Hi,

i have a json response where there is a value like :

slurperresponse.data.debt[0].totalValue = [50]

if i assert like this:

assert slurperresponse.data.debt[0].totalValue = 50

it doesn't accept because [50] is not int

How can i convert [50] into 50 ?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Frequent Contributor

Re: How to convert array to intger with groovy ?

Found solution with this:

int b = a.collect { "$it" }.join( '' ) as int 

Sorry for spam.

View solution in original post

3 REPLIES 3
Highlighted
Frequent Contributor

Re: How to convert array to intger with groovy ?

Found solution with this:

int b = a.collect { "$it" }.join( '' ) as int 

Sorry for spam.

View solution in original post

Highlighted
Community Hero

Re: How to convert array to intger with groovy ?

Possible to show json sample?


Regards,
Rao.
Highlighted
Frequent Contributor

Re: How to convert array to intger with groovy ?

json sample:

{
"data" : [
{
"Debt" : {
"Id" : 2980,
"Name" : "MHN",
"Rate" : 1.8,
"market" : "AH"
"block" : true,
"aYield" : 2.3,
"aSYield" : 2.7,
"Qty" : 20,
"totalValue" : 1999.47
}
]
},