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.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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?
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.
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 :-)
Hello @Tony Casey , 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]
Just make sure to remove the array braces [ ]
from the schema defined.
Please let me know if there are any concerns. Thank you!