From time to time you may be forced to deal with JSON objects in Power Automate that contain duplicate property names. Consider this object, for example:
{
"Id": 42,
"Name": "Fixing the machine",
"From": "Edison",
"Total": 1000,
"Items": [
{
"Id": 1,
"Name": "Hammering",
"Subtotal": 1
},
{
"Id": 2,
"Name": "Knowing Where to Hammer",
"Subtotal": 999
}
]
}
To make this object maker-friendly, the common approach is to use Parse JSON action and derive schema from the data itself.
When done, maker can use properties as dynamic values. In our data, unfortunately, some properties have identical names (Id and Name) even though their path is different.
As it turns out, object schema can be enriched with “title” and “description” annotations. For example, let’s describe Ids and Names
{
"type": "object",
"properties": {
"Id": {
"type": "integer",
"title": "Invoice ID",
"description": "Unique invoice identifier"
},
"Name": {
"type": "string",
"title": "Invoice name"
},
"From": {
"type": "string"
},
"Total": {
"type": "integer"
},
"Items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"Id": {
"type": "integer",
"title": "Invoice line item ID",
"description": "Line item number unique within the invoice"
},
"Name": {
"type": "string",
"description": "Line item name, not to be confused with invoice name"
},
"Subtotal": {
"type": "integer"
}
},
"required": [
"Id",
"Name",
"Subtotal"
]
}
}
}
}
The result is the game changer:
Now you can have your JSON and eat it too.
Cover photo by Natalia Yakovleva on Unsplash
Trick is short but actually game changer. Thanks.
Really helpful , Thanks for sharing awesome post……