在Java服务任务中获取Json请求值

时间:2017-03-17 04:20:28

标签: java bpm camunda

无法读取Java服务任务

中的JSON请求值
Input JSON

 {
  "variables": {
    "event":{
     "cat" : {"value" : "abc", "type" : "String"},
     "reason": {"value":"abc Changes","type":"String"},
     "link": {"value":"http://localhost:8080/camunda/app","type":"String"} 
      } 
   }
}

Java服务任务

public class ParseRequest implements JavaDelegate {

@Override
public void execute(DelegateExecution execution) throws Exception
{

// Tried one way as below not working - execution.getVariable("event") is coming null

 String jo1 = JSONObject.quote(execution.getVariable("event").toString());
 JsonValue event2 = SpinValues.jsonValue((String) jo1).create();        
 String catValue = event2.getValue().prop("cat").toString();


// Tried as below not working getting Error - org.camunda.bpm.engine.variable.impl.value.NullValueImpl cannot be cast to org.camunda.spin.plugin.variable.value.JsonValue

JsonValue customer = execution.getVariableTyped("event");
String catValue2 = customer .getValue().prop("cat").toString();

}

在我们的项目中首次使用Camunda。任何帮助表示赞赏。 请指导我这里

0 个答案:

没有答案