web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Answered

Parse JSON Schema

(0) ShareShare
ReportReport
Posted on by 7

Hello,

 

I am trying to create a schema for JSON data I am receiving from a HTTP get operation.  Sample JSON and schema (created by flow) is below.  Trouble seems to be with the notes field which is returned differently depending on if its empty or contains notes.

 

How do I fix the schema to account for this?  (I can't change the JSON as its from an external API)

 

Thanks in advance!

 

Error

 

[
 {
 "message": "Invalid type. Expected Object but got Array.",
 "lineNumber": 0,
 "linePosition": 0,
 "path": "[1].notes",
 "schemaId": "#/items/properties/notes",
 "errorType": "type",
 "childErrors": []
 },
 {
 "message": "Invalid type. Expected Object but got Array.",
 "lineNumber": 0,
 "linePosition": 0,
 "path": "[2].notes",
 "schemaId": "#/items/properties/notes",
 "errorType": "type",
 "childErrors": []
 },
 {
 "message": "Invalid type. Expected Object but got Array.",
 "lineNumber": 0,
 "linePosition": 0,
 "path": "[3].notes",
 "schemaId": "#/items/properties/notes",
 "errorType": "type",
 "childErrors": []
 },
 {
 "message": "Invalid type. Expected Object but got Array.",
 "lineNumber": 0,
 "linePosition": 0,
 "path": "[9].notes",
 "schemaId": "#/items/properties/notes",
 "errorType": "type",
 "childErrors": []
 }
]

 

Example Schema

 

{
 "type": "array",
 "items": {
 "type": "object",
 "properties": {
 "id": {
 "type": "string"
 },
 "employeeId": {
 "type": "string"
 },
 "status": {
 "type": "object",
 "properties": {
 "lastChanged": {
 "type": "string"
 },
 "lastChangedByUserId": {
 "type": "string"
 },
 "status": {
 "type": "string"
 }
 }
 },
 "name": {
 "type": "string"
 },
 "start": {
 "type": "string"
 },
 "end": {
 "type": "string"
 },
 "created": {
 "type": "string"
 },
 "type": {
 "type": "object",
 "properties": {
 "id": {
 "type": "string"
 },
 "name": {
 "type": "string"
 },
 "icon": {
 "type": "string"
 }
 }
 },
 "amount": {
 "type": "object",
 "properties": {
 "unit": {
 "type": "string"
 },
 "amount": {
 "type": "string"
 }
 }
 },
 "actions": {
 "type": "object",
 "properties": {
 "view": {
 "type": "boolean"
 },
 "edit": {
 "type": "boolean"
 },
 "cancel": {
 "type": "boolean"
 },
 "approve": {
 "type": "boolean"
 },
 "deny": {
 "type": "boolean"
 },
 "bypass": {
 "type": "boolean"
 }
 }
 },
 "dates": {
 "type": "object",
 "properties": {
 "2020-05-01": {
 "type": "string"
 },
 "2020-05-02": {
 "type": "string"
 },
 "2020-05-03": {
 "type": "string"
 },
 "2020-05-04": {
 "type": "string"
 },
 "2020-05-05": {
 "type": "string"
 }
 }
 },
 "notes": {
 "type": "object",
 "properties": {
 "employee": {
 "type": "string"
 }
 }
 }
 },
 "required": [
 "id",
 "employeeId",
 "status",
 "name",
 "start",
 "end",
 "created",
 "type",
 "amount",
 "actions",
 "dates",
 "notes"
 ]
 }
}

 

Example JSON

 

[
 {
 "id": "4602",
 "employeeId": "204",
 "status": {
 "lastChanged": "2020-02-27",
 "lastChangedByUserId": "2677",
 "status": "canceled"
 },
 "name": "Homer Simpson",
 "start": "2020-05-01",
 "end": "2020-05-05",
 "created": "2020-02-04",
 "type": {
 "id": "82",
 "name": "Vacation",
 "icon": "palm-trees"
 },
 "amount": {
 "unit": "days",
 "amount": "3"
 },
 "actions": {
 "view": true,
 "edit": false,
 "cancel": false,
 "approve": false,
 "deny": false,
 "bypass": false
 },
 "dates": {
 "2020-05-01": "1",
 "2020-05-02": "0",
 "2020-05-03": "0",
 "2020-05-04": "1",
 "2020-05-05": "1"
 },
 "notes": {
 "employee": "vacation "
 }
 },
 {
 "id": "4974",
 "employeeId": "99",
 "status": {
 "lastChanged": "2020-04-28",
 "lastChangedByUserId": "2686",
 "status": "approved"
 },
 "name": "Bart Simpson",
 "start": "2020-05-05",
 "end": "2020-05-05",
 "created": "2020-04-03",
 "type": {
 "id": "82",
 "name": "Vacation",
 "icon": "palm-trees"
 },
 "amount": {
 "unit": "days",
 "amount": "1"
 },
 "actions": {
 "view": true,
 "edit": false,
 "cancel": false,
 "approve": false,
 "deny": false,
 "bypass": false
 },
 "dates": {
 "2020-05-05": "1"
 },
 "notes": []
 }
]

 

 

Categories:
  • Verified answer
    v-litu-msft Profile Picture
    Microsoft Employee on at

    Hi @PancakeMaker99,

     

    If the notes are not sure whether it has value, you could create multiple types of the note:

    "notes": {
     "type": ["object","array"],
     "properties": {
     "employee": {
     "type": "string"
     }
     }
     }

     

    So, the whole JSON schema could be:

    {
     "type": "array",
     "items": {
     "type": "object",
     "properties": {
     "id": {
     "type": "string"
     },
     "employeeId": {
     "type": "string"
     },
     "status": {
     "type": "object",
     "properties": {
     "lastChanged": {
     "type": "string"
     },
     "lastChangedByUserId": {
     "type": "string"
     },
     "status": {
     "type": "string"
     }
     }
     },
     "name": {
     "type": "string"
     },
     "start": {
     "type": "string"
     },
     "end": {
     "type": "string"
     },
     "created": {
     "type": "string"
     },
     "type": {
     "type": "object",
     "properties": {
     "id": {
     "type": "string"
     },
     "name": {
     "type": "string"
     },
     "icon": {
     "type": "string"
     }
     }
     },
     "amount": {
     "type": "object",
     "properties": {
     "unit": {
     "type": "string"
     },
     "amount": {
     "type": "string"
     }
     }
     },
     "actions": {
     "type": "object",
     "properties": {
     "view": {
     "type": "boolean"
     },
     "edit": {
     "type": "boolean"
     },
     "cancel": {
     "type": "boolean"
     },
     "approve": {
     "type": "boolean"
     },
     "deny": {
     "type": "boolean"
     },
     "bypass": {
     "type": "boolean"
     }
     }
     },
     "dates": {
     "type": "object",
     "properties": {
     "2020-05-01": {
     "type": "string"
     },
     "2020-05-02": {
     "type": "string"
     },
     "2020-05-03": {
     "type": "string"
     },
     "2020-05-04": {
     "type": "string"
     },
     "2020-05-05": {
     "type": "string"
     }
     }
     },
     "notes": {
     "type": ["object","array"],
     "properties": {
     "employee": {
     "type": "string"
     }
     }
     }
     },
     "required": [
     "id",
     "employeeId",
     "status",
     "name",
     "start",
     "end",
     "created",
     "type",
     "amount",
     "actions",
     "dates",
     "notes"
     ]
     }
    }

     

    Best Regards,
    Community Support Team _ Lin Tu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 430

#2
11manish Profile Picture

11manish 341 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 282

Last 30 days Overall leaderboard