WSO2 脚本中介的 setPayloadJSON 中是否存在换行符错误?

Is there a bug with newline character in setPayloadJSON in WSO2 script mediator?

我创建了一个简单的 API,如下所示:

<api xmlns="http://ws.apache.org/ns/synapse" name="test_newlineScript" context="/test_newlineScript">
   <resource methods="POST" uri-template="/test">
      <inSequence>
         <script language="js">
            var payload = mc.getPayloadJSON();
            mc.setPayloadJSON(payload);
         </script>
         <respond/>
      </inSequence>
      <outSequence/>
      <faultSequence/>
   </resource>
</api>

这只是一个示例 API 来说明问题。实际实现包含一些数据映射。

这段代码应该给我一个与发送到此 API 的请求相同的响应,而且它大部分都有效。

请求{"test": "abc"}给出这样的响应{"test": "abc"}

但是请求{"test": "a\nbc"}报错unterminated string literal

当然,在收到此错误后,我尝试了此请求 {"test": "a\nbc"} 并得到了 {"test": "a\nbc"} 响应。

知道这是否只是一个错误吗?还是我遗漏了什么?

尝试使用 NashornJS 而不是 WSO2 中的默认 JS 脚本中介。下面给出了在 Script Mediator

中使用 NashornJS 库的示例
<script language="nashornJs" >
    var payload = mc.getPayloadJSON();
    mc.setPayloadJSON(payload);
</script>