我一直在努力解决以下问题。我有一个 xml,必须使用 azure 上的液体映射将其转换为 json。有时一个节点包含 xml 编码的双引号,像这样:
<node>
<value>"some string"and the rest</value>
</node>
我的液体映射如下所示:
"name":"{{ node.value }}"
映射的结果是以下错误:
{
"Code": "IncorrectLiquidTransformOutputType",
"Message": "An error occurred while converting the transformed value to JSON. The transformed value is not a valid JSON. 'After parsing a value an unexpected character was encountered: s. Path '[205].node[9].value', line 32305, position 13.'",
"Details": [
{
"Code": "IncorrectLiquidTransformOutputType",
"Message": "{\"ClassName\":\"Microsoft.Azure.Function.Common.ErrorResponses.ErrorMessageException\",\"Message\":\"An error occurred while converting the transformed value to JSON. The transformed value is not a valid JSON. 'After parsing a value an unexpected character was encountered: s. Path '[205].node[9].name', line ....., position 13.'\",\"Data\":null,\"InnerException\":{\"ClassName\":\"Newtonsoft.Json.JsonReaderException\",\"Message\":\"After parsing a value an unexpected character was encountered: s. Path '[205].node[9].value'....",
"Details": null,
"InnerError": null
}
],
"InnerError": null
}
这意味着字符“被正确解码为双引号,然后它会导致json出现问题。我需要像这样保留这个字符:
"name":"\"some string\"and the rest"
任何想法怎么做?