Thursday, 15 September 2011

java - executing toString() in Eval () - Groovy (method call in Gstring) -



java - executing toString() in Eval () - Groovy (method call in Gstring) -

consider this, value of

$respnode

is

respjson.seatbid[0].bid[0].price

i trying run

eval.me('respjson', respjson, "assert $respnode.tostring() == '$avalue'")

but getting error

[no such property: tostring class: java.lang.string]

when run (directly, without eval() )

assert respjson.seatbid[0].bid[0].price.tostring()==avalue

it runs fine (no error)

the below works fine (without tostring() )

eval.me('respjson', respjson, "assert $respnode == '$avalue'")

any ideas , how run tostring() eval() thanks!

a method phone call in gstring needs curly brackets, otherwise parents don't parsed part of call:

class foo { def getbar() { 'get bar' } def bar() { 'method bar' } } foo = new foo() assert "$foo.bar()".tostring() == "get bar()" assert "${foo.bar()}".tostring() == "method bar"

java groovy eval

No comments:

Post a Comment