这看起来很明显,但不知何故它对我不起作用。我正在尝试在 Microsoft Azure 上的逻辑应用程序中构建解决方案,但我无法将 JSON 对象转换为 XML。
我的要求是执行存储过程并以 XML 格式保存响应。默认情况下,SQL 执行存储过程操作返回以下 JSON 格式的响应,
{
"OutputParameters": { },
"ReturnCode": 0,
"ResultSets": {
"Table1": [
{
"ProductID": 680,
"Name": "HL Road Frame - Black, 58",
"ProductNumber": "FR-R92B-58",
"Color": "Black",
"StandardCost": 1059.31,
"ListPrice": 1431.5,
"Size": "58",
"Weight": 1016.04
},
{
"ProductID": 706,
"Name": "HL Road Frame - Red, 58",
"ProductNumber": "FR-R92R-58",
"Color": "Red",
"StandardCost": 1059.31,
"ListPrice": 1431.5,
"Size": "58",
"Weight": 1016.04
}]
}
}
然后,上述响应将用于“创建 Blob”操作,以将响应保存在 Azure 上的 Blob 中。
This link https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language说逻辑应用程序提供 xml 函数将字符串或 JSON 对象转换为 XML,但这似乎没有按预期工作。我尝试了下面的表达但没有任何作用,
- @xml(body('执行存储过程')?['结果集'])
错误:模板语言函数“xml”参数无效。提供的值无法转换为 XML:“此文档已有一个‘DocumentElement’节点。”。请参见https://aka.ms/logicexpressions#xml https://aka.ms/logicexpressions#xml了解使用详情。
- @xml(body('执行存储过程')?['结果集']['表1'])
错误:模板语言函数“xml”期望其参数是字符串或对象。提供的值是“Array”类型。请参见https://aka.ms/logicexpressions#xml https://aka.ms/logicexpressions#xml了解使用详情。
我想要的只是将此 JSON 转换为 XML,如下所示,
<Root><Product>....</Product><Product>....</Product></Root>
替代解决方案可能是调用 Azure 函数并在 C# 代码中将此 JSON 转换为 XML。但在尝试替代解决方案之前,我想知道我做错了什么。