1

I get the status code using the following code.

String statusCode = ((Map<String,String>) product.getStatus().get("abc")).get("code");

I want to use jexl expression to get value.

JexlEngine jexlEngine = new JexlEngine();
Expression expression = jexlEngine.createExpression("((Map<String,String>) product.getStatus().get(\"abc\")).get(\"description\")");
JexlContext jexlContext = new MapContext();
jexlContext.set("product", product);
String statusCode = expression.evaluate(jexlContext);

I am getting org.apache.commons.jexl2.parser.ParseException at 'createExpression'. How do I create jexl expression to get statusCode.

choom
  • 45
  • 1
  • 11

1 Answers1

0

With Jexl 3.0 this works:

JexlExpression expression = jexlEngine.createExpression("product.status[\"abc\"][\"description\"]");
jorgegm
  • 166
  • 5