cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
oappdev
Advocate V
Advocate V

Parse JSON Schema - Required properties are missing from object.

Hello Power Automate Community,

 

So I have the following fields:

First NameRow1,Last NameRow1
First NameRow1_2,LastName Row1_2
First NameRow1_3,LastName Row1_3
First NameRow1_4,LastName Row1_4
First NameRow1_5,LastName Row1_5

 

Still learning JSON,  What would be an sample JSON to Fill in the rest of the pending fields. 

 

INPUT Content:

 

 

[
    {
        "First NameRow1": "John",
        "Last NameRow1": "Doe",
    },
    {
        
        "First NameRow1": "John",
        "Last NameRow1": "Doe1",
        
    }
]

 

 

 

Schema:

 

 

[
    {
        "First NameRow1": "",
        "Last NameRow1": "",
    },
    {
        "First NameRow1_2": "",
        "Last NameRow1_2": "",        
    },
    {
        "First NameRow1_3": "",
        "Last NameRow1_3": "",        
    },
    {
        "First NameRow1_4": "",
        "Last NameRow1_4": "",        
    },
    {
        "First NameRow1_5": "",
        "Last NameRow1_5": ""
    },
"required": [
      "First NameRow1",
      "Last NameRow1",
      "First NameRow1_2",
      "Last NameRow1_2",
      "First NameRow1_3",
      "Last NameRow1_3",
      "First NameRow1_4",
      "Last NameRow1_4",
      "First NameRow1_4",
      "Last NameRow1_4",
      "First NameRow1_5",
      "Last NameRow1_5"

    ]
 }
]

 

 

 

OUTPUT Errors:

 

 

[
  {
    "message": "Required properties are missing from object: First NameRow1_2, Last NameRow1_2,First NameRow1_3,Last NameRow1_3,First NameRow1_4,Last NameRow1_4,First NameRow1_5,Last NameRow1_5",
    "lineNumber": 0,
    "linePosition": 0,
    "path": "[0]",
    "value": [
      "First NameRow1_2",
      "Last NameRow1_2",
      "First NameRow1_3",
      "Last NameRow1_3",
      "First NameRow1_4",
      "Last NameRow1_4",
      "First NameRow1_5",
      "Last NameRow1_5"
    ],
    "schemaId": "#/items",
    "errorType": "required",
    "childErrors": []
  }
]

 

 

 

As always, Thank you so much in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

A JSON array is denoted by the use of square brackets [].  Inside the brackets are comma delimited records denoted by curly braces {}.  Each record consists of properties that have a "Name": and "value".  Multiple properties are separated by commas.  So your input is almost a valid JSON array.  The commas after the last properties should be removed.  The following is a valid JSON array.

[
    {
        "First NameRow1": "John",
        "Last NameRow1": "Doe"
    },
    {
        
        "First NameRow1": "Paul",
        "Last NameRow1": "Stork"
        
    }
]

 Note that the property names are repeated for each record.  You don't want different property names.  The schema for the JSON array above is

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "First NameRow1": {
                "type": "string"
            },
            "Last NameRow1": {
                "type": "string"
            }
        },
        "required": [
            "First NameRow1",
            "Last NameRow1"
        ]
    }
}

You'll notice the section at the end called "required" this is the list of properties that each object in the array MUST have.  In your example you changed the property name for each object and listed all the variations as required.  But each object only had a few of those properties.  That's why you are getting an error.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
Pstork1
Dual Super User III
Dual Super User III

A JSON array is denoted by the use of square brackets [].  Inside the brackets are comma delimited records denoted by curly braces {}.  Each record consists of properties that have a "Name": and "value".  Multiple properties are separated by commas.  So your input is almost a valid JSON array.  The commas after the last properties should be removed.  The following is a valid JSON array.

[
    {
        "First NameRow1": "John",
        "Last NameRow1": "Doe"
    },
    {
        
        "First NameRow1": "Paul",
        "Last NameRow1": "Stork"
        
    }
]

 Note that the property names are repeated for each record.  You don't want different property names.  The schema for the JSON array above is

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "First NameRow1": {
                "type": "string"
            },
            "Last NameRow1": {
                "type": "string"
            }
        },
        "required": [
            "First NameRow1",
            "Last NameRow1"
        ]
    }
}

You'll notice the section at the end called "required" this is the list of properties that each object in the array MUST have.  In your example you changed the property name for each object and listed all the variations as required.  But each object only had a few of those properties.  That's why you are getting an error.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Thank you so much! @Pstork1 Will give it a try. 

@Pstork1 What l'm i missing or doing wrong?

 

Error:

 

Additional text encountered after finished reading JSON content: ,. Path '', line 4, position 1.

 

JSONError.PNG

 

Sorry, been under a lot of pressure.

Pstork1
Dual Super User III
Dual Super User III

From what I can see of the input, you've got two JSON records, but no Array.  There should be square brackets around the JSON for it to be an array.

Yours

{
 record
},
{
 record2
}

should be 

[
{
 record
},
{
 record2
}
]


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (30,812)