Thabo
Thabo

Reputation: 1554

Azure logic apps Parse Json throws an error

Background

I have a custom connector which returns a JSON response .I am trying to parse the response to JSON since i want to use the response later in other flows. So that I am using Parse JSON Action from Data operations connector. Following is the JSON response and the JSON schema i provided to Parse JSON.

Response

[
   [
      {
         "key":"Customer_Key",
         "value":{
            "id":"abfa48ad-392d-e511-80d3-005056b34214",
            "name":"90033"
         }
      },
      {
         "key":"Status",
         "value":"Done"
      }
   ]
]

Schema

{
    "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"
            ]
        }
    }
}

Exception

  {
            "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": []
        },

Any one knows what is the issue on this ?How we can I convert above json response

Upvotes: 0

Views: 4108

Answers (2)

George Chen
George Chen

Reputation: 14324

Looks like the Use sample payload to generate schema couldn't generate right schema. So you could go to this liquid studio site and paste the JSON payload then click the Generate Schema button, then you will get the Json Schema.

enter image description here

And I test the Schema, it worked perfectly. enter image description here

Hope this could help you, if you still have other questions,please let me know.

Upvotes: 2

Ketan
Ketan

Reputation: 1550

Schema looks incorrect. try with the below schema:

{
  "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"
          ]
        }
      ]
    }
  ]
}

Upvotes: 2

Related Questions