WSO2 ESB在有效负载工厂中添加斜杠

问题描述 投票:1回答:1

我正在使用payloadfactory介体并在arg中添加单个斜杠值,但ESB将其转换为双斜杠,以下是与响应一起使用的payloadfactory

 <payloadFactory media-type="json">
     <format>
        {
            "channel": { 
                    "text": "this is test Text $1"
            }
        }
     </format>
        <args>
            <arg evaluator="xml" value="\n" />
        </args>
  </payloadFactory>

有效负载设置为

{
    "channel": { 
        text": "this is test Text \\n"
    }
}

而且我想要。

{
    "channel": { 
        "text": "this is test Text \n"
    }
}

P.S“ \ n”将在上面的属性调解器中设置,我将通过arg将其放入有效负载工厂,这就是为什么我不能直接使用其格式的原因。

谢谢。

wso2 wso2esb wso2ei
1个回答
1
投票

这似乎是ESB中的限制。请尝试以下解决方法。 (是的,我知道。这似乎有点过分了)

<enrich>
        <source type="inline" clone="true">{
    "replace" : "\n"
}</source>
        <target type="body"/>
    </enrich>
    <property name="NEW_LINE" expression="json-eval($.replace)" scope="default" type="STRING"/>
    <payloadFactory media-type="json">
        <format>        {
            "channel": { 
                    "text": "this is test Text $1"
            }
        }
     </format>
        <args>
            <arg literal="true" evaluator="xml" expression="$ctx:NEW_LINE"/>
        </args>
    </payloadFactory>
© www.soinside.com 2019 - 2024. All rights reserved.