wso2 使用响应和条件

wso2 using the response and conditional

是否可以将响应中的 json 用作 属性,然后用它来制作条件语句?我研究了条件路由器和序列来实现这一点,但我不知道如何获得响应并将其放入 属性 中介或仅将其用于条件路由器。

示例我有这个响应

{
    "fruit": "apple"
}

然后我想检查关键水果是不是苹果。

if (response.fruit == "apple") {
    callMediator();
} else {
    callOtherMediator();
}

设置为属性:

<property name="fruit" expression="//fruit"/>

要检查,请使用 Filter Mediator

<filter source="$ctx:fruit" regex="apple">
      <then>
          <send/>
      </then>
      <else>
          <drop/>
      </else>
</filter>