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

在Java服务任务中获取Json请求值,java,business-process-management,camunda,Java,Business Process Management,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服务任务中的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"} 
      } 
   }
}
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();

}
Java服务任务

Input JSON

 {
  "variables": {
    "event":{
     "cat" : {"value" : "abc", "type" : "String"},
     "reason": {"value":"abc Changes","type":"String"},
     "link": {"value":"http://localhost:8080/camunda/app","type":"String"} 
      } 
   }
}
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。感谢您的帮助。
请在这里指导我

您使用的JSON库是什么?有必要知道您在做什么。请发布您的流程模型。我们还需要知道在哪里定义变量以及在哪个范围上定义变量。使用哪个JSON库是不相关的。问题显然与此无关。泽尔登的评论是相关的。编写一个调试块,迭代“execution.getVariables()”映射,查看定义了哪些变量(如果有)。从用户输入中获取的变量,我们已经公开了一个Camunda Rest APi,并在用户调用该进程时启动该进程。这是一个简单的过程,只是接收,然后我们有一个用户任务来批准或拒绝请求。