JSON schema inside Parse JSON action. "required" array versus field type

13 views Asked by At

I have a scheduled power automate flow which read a csv file coming from 3rd party system. The file will be added inside OneDrive and I am reading the file from there. Now inside the Parse JSON action, I have this schema:-

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "Brand": {
                "type": "string"
            },
            "OOH_price_list": {
                "type": "object",
                "properties": {
                    "Net_Total": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "SalesTax": {},
                    "Grand_Total": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "Total": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "DIscount": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "BR_price_list": {
                "type": "object",
                "properties": {
                    "Net_Total": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "Grand_Total": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "Amount_In_Words": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "Sales_Tax": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "OOH_media_list": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "Network": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "Amount": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "Duration": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "of_Faces": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "Start_Date": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "End_Date": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "Delivery Date": {
                            "type": [
                                "string",
                                "null"
                            ]
                        }
                    },
                    "required": [
                        "Network",
                        "Amount",
                        "Duration",
                        "of_Faces",
                        "Start_Date",
                        "End_Date",
                        "Delivery Date"
                    ]
                }
            },
            "blue_river_list": {
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "Network": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "Amount": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "Cost_Face": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "of_Faces": {
                            "type": [
                                "string",
                                "null"
                            ]
                        },
                        "Start_Date": {
                            "type": [
                                "string",
                                "null"
                            ]
                        }
                    },
                    "required": [
                        "Network",
                        "Amount",
                        "Cost_Face",
                        "of_Faces",
                        "Start_Date"
                    ]
                }
            },
            "Contract_Number": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "Client Name": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "Sector": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "No of Faces": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "Sales Person": {
                "type": [
                    "string",
                    "null"
                ]
            }
        },
        "required": [
            "Brand",
            "OOH_price_list",
            "BR_price_list",
            "OOH_media_list",
            "blue_river_list",
            "Contract_Number",
            "Client Name",
            "Sector",
            "No of Faces",
            "Sales Person"
        ]
    }
}
 

 

But I have the following questions about it:-

1)At the end of the schema there is an array named "required" with those values:-

"required": [
            "Brand",
            "OOH_price_list",
            "BR_price_list",
            "OOH_media_list",
            "blue_river_list",
            "Contract_Number",
            "Client Name",
            "Sector",
            "No of Faces",
            "Sales Person"
        ]
 

so, what does this array mean exactly? does it mean that if the JSON file is missing any of those fields the Parse JSON will raise an exception? and if this is the case, will it also raise an exception if the field is there but have a null value?

2)Inside the schema, we have a "required" array + some fields have a nullable type. For example, the field named "Sector" is defined inside the "required" array + has this type:-

"Sector": {
                "type": [
                    "string",
                    "null"
                ]
            },
 

so which will win? the value inside the "required" array or the above type which is a string that can be null? so at the end can we have a nullable value inside the "Sector" field?

Thanks in advance for any help.

0

There are 0 answers