How can I convert this String
variable to a List
?
def ids = "[10, 1, 9]"
I tried with: as List
and toList();
def l = Eval.me(ids)
Takes the string of groovy code (in this case "[10,1,9]") and evaluates it as groovy. This will give you a list of 3 ints.
def l = ids.split(',').collect{it as int}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With