我怎么知道 json 正文是否有内容?
How can I know if a json body has content?
我有一个过滤器可以在 body 是否有 body 时执行一些代码,因为 enrich mediator 不能处理 null body,但我不知道表达式
我尝试了 boolean($body) 但不起作用
<filter regex="default_regex" source="boolean($body)">
<then>
<enrich>
<source clone="true" type="body"/>
<target property="payload" type="property"/>
</enrich>
</then>
<else>
<log level="full"/>
</else>
能否将正则表达式更新为 true 并试一试。
<filter regex="true" source="boolean($body)">
<then>
<enrich>
<source clone="true" type="body"/>
<target property="payload" type="property"/>
</enrich>
</then>
<else>
<log level="full"/>
</else>
如果它没有获得 json 有效载荷,请尝试将其分配给 属性 并进行过滤。
<property name="JsonBody" expression="json-eval($.)/>
<filter regex="true" source="boolean($ctx:JsonBody)">
<then>
<enrich>
<source clone="true" type="body"/>
<target property="payload" type="property"/>
</enrich>
</then>
<else>
<log level="full"/>
</else>
谢谢
我有一个过滤器可以在 body 是否有 body 时执行一些代码,因为 enrich mediator 不能处理 null body,但我不知道表达式
我尝试了 boolean($body) 但不起作用
<filter regex="default_regex" source="boolean($body)">
<then>
<enrich>
<source clone="true" type="body"/>
<target property="payload" type="property"/>
</enrich>
</then>
<else>
<log level="full"/>
</else>
能否将正则表达式更新为 true 并试一试。
<filter regex="true" source="boolean($body)">
<then>
<enrich>
<source clone="true" type="body"/>
<target property="payload" type="property"/>
</enrich>
</then>
<else>
<log level="full"/>
</else>
如果它没有获得 json 有效载荷,请尝试将其分配给 属性 并进行过滤。
<property name="JsonBody" expression="json-eval($.)/>
<filter regex="true" source="boolean($ctx:JsonBody)">
<then>
<enrich>
<source clone="true" type="body"/>
<target property="payload" type="property"/>
</enrich>
</then>
<else>
<log level="full"/>
</else>
谢谢