Parse Json schema response

Anonymous
2021-07-19T22:38:35.793+00:00

I have searched high and low for this and cannot find a solution.

I want to create a response schema for my Logic App.

The app selects data from the document db which includes metadata fields like _etag, _ts, _rid etc.

I want to remove those fields from the reponse object.

I tried Parse Json and it just ignores the schema and adds in all the fields I don't want.

Here is the input it gets..

[
  {
    "id": "1",
    "provider": "Microsoft",
    "examCode": "AZ-900",
    "body": "Question 1 about blah blah blah",
    "_rid": "vLoPANg8VjcBAAAAAAAAAA==",
    "_self": "dbs/vLoPAA==/colls/vLoPANg8Vjc=/docs/vLoPANg8VjcBAAAAAAAAAA==/",
    "_etag": "\"79001ad3-0000-0d00-0000-60e823830000\"",
    "_attachments": "attachments/",
    "_ts": 1625826179
  }
]

Here is the schema..

{
  "type": "array",
  "items": {
    "type": "object",
    "properties": {
      "body": {
        "type": "string"
      },
      "examCode": {
        "type": "string"
      },
      "id": {
        "type": "string"
      },
      "provider": {
        "type": "string"
      }
    },
    "required": [
      "id",
      "provider",
      "examCode",
      "body"
    ]
  }
}

Here is the output..

[
  {
    "id": "1",
    "provider": "Microsoft",
    "examCode": "AZ-900",
    "body": "Question 1 about blah blah blah",
    "_rid": "vLoPANg8VjcBAAAAAAAAAA==",
    "_self": "dbs/vLoPAA==/colls/vLoPANg8Vjc=/docs/vLoPANg8VjcBAAAAAAAAAA==/",
    "_etag": "\"79001ad3-0000-0d00-0000-60e823830000\"",
    "_attachments": "attachments/",
    "_ts": 1625826179
  }
]

So what's the point of Parse Json if it doesn't follow the schema?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
{count} votes

Answer accepted by question author
  1. Anonymous
    2021-07-27T10:50:59.157+00:00

    @ChaitanyaNaykodi-MSFT

    So, back to the original question then.

    The ParseJson will NOT parse an array into the supplied schema.

    If I want to get the individual fields, I will have to loop through the array, add them to a new array and output that one, which I have done.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2021-07-21T07:58:49.727+00:00

    It was receiving an array from the Cosmos db.

    I have changed it now, to loop through the array and add to a variable.

    A nicer solution would be for the ParseJson process to do the work for me :-)

    116654-image.png

    0 comments No comments

  2. ChaitanyaNaykodi-MSFT 27,651 Reputation points Microsoft Employee Moderator
    2021-07-23T21:32:27.817+00:00

    Hello @Anonymous , apologies for the delay in my response.

    If the data received from Cosmos DB always has a single element in the array you can try to implement the solution as shown below without looping through the data.

    In Parse JSON operation you can access the first object of the array by editing the Content in following manner triggerBody()[0]

    117582-image.png

    Just make sure to remove the array braces [ ] from the schema defined.

    Please let me know if there are any concerns. Thank you!


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.