2

I have following string:

data = ["myKey": "myValue"]

and want to evaluate it as map:

def map = evaluate(data)

Looks like I'm doing something wrong but I get

groovy.lang.MissingMethodException: No signature of method: DUMMY.evaluate() is

 applicable for argument types: (java.lang.String) values: [["myKey": "myValue"]]

So my question is how to perform such evaluation?

Vladimir
  • 12,753
  • 19
  • 62
  • 77

1 Answers1

6

If I understand your question correctly, you have a String like so:

data = '["myKey": "myValue"]'

If that is the case, you can evaluate it to a Map by using the Eval class

map = Eval.me( data )
tim_yates
  • 167,322
  • 27
  • 342
  • 338