背景
我有一个自定义连接器,它返回JSON响应。我试图将响应解析为JSON,因为我想稍后在其他流中使用该响应。这样我就可以从数据操作连接器使用Parse JSON Action。以下是我提供给JSON解析的JSON响应和JSON模式。
响应
[
[
{
"key":"Customer_Key",
"value":{
"id":"abfa48ad-392d-e511-80d3-005056b34214",
"name":"90033"
}
},
{
"key":"Status",
"value":"Done"
}
]
]
架构
{
"type": "array",
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"required": [
"key",
"value"
]
}
}
}
例外
{
"message": "Invalid type. Expected Object but got String.",
"lineNumber": 0,
"linePosition": 0,
"path": "[0][2].value",
"value": "90033",
"schemaId": "#/items/items/properties/value",
"errorType": "type",
"childErrors": []
},
任何人都知道这是什么问题?我们如何在json响应上方进行转换
答案 0 :(得分:2)
架构看起来不正确。尝试使用以下架构:
{
"type": "array",
"items": [
{
"type": "array",
"items": [
{
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"name"
]
}
},
"required": [
"key",
"value"
]
},
{
"type": "object",
"properties": {
"key": {
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"key",
"value"
]
}
]
}
]
}
答案 1 :(得分:1)
看起来Use sample payload to generate schema
无法生成正确的架构。
因此,您可以转到此 liquid studio site 并粘贴JSON有效负载,然后单击 Generate Schema (生成模式)按钮,然后将获得Json Schema。
希望这对您有帮助,如果您还有其他问题,请告诉我。