Home > Software design >  Returning specific property (text) from JSON object file in azure logic apps
Returning specific property (text) from JSON object file in azure logic apps

Time:08-12

I'm not sure if I've horribly messed up the JSON file, or if I have encountered something that I am truly misunderstanding. Below is my JSON schema.

JSON SCHEMA

So when I parse it, it looks like the below. Parsed JSON

Which to me looks pretty good. The problem is when I try to get a specific line out of the JSON to put in a automated email template, I get either nothing or the whole JSON output in one line. This is my work flow below, I have tried initializing variables using variables('variable1')['0'] or variables('variable1')['AP Outage Title'] , filter array, etc etc. Do I initialize a variable and place that specific property of the JSON file into that variable? I feel like I am so close but missing something critical.

I believe the JSON is an JSON object, but I could be wrong about that.

Work Flow

CodePudding user response:

Instead of constructing the JSON Schema you can directly build a JSON Schema using Use sample payload to generate schema and then paste your JSON. Doing this will automatically generate a JSON Schema for you.

STEP - 1:

enter image description here

STEP - 2:

enter image description here

RESULT:

enter image description here

Now you can generated with the objects inside the JSON

enter image description here

Below is the schema that got generated using the above steps.

{
    "properties": {
        "body": {
            "properties": {
                "AP Outage Title": {
                    "properties": {
                        "0": {
                            "type": "string"
                        },
                        "1": {
                            "type": "string"
                        },
                        "2": {
                            "type": "string"
                        },
                        "3": {
                            "type": "string"
                        },
                        "4": {
                            "type": "string"
                        },
                        "5": {
                            "type": "string"
                        },
                        "6": {
                            "type": "string"
                        },
                        "7": {
                            "type": "string"
                        },
                        "8": {
                            "type": "string"
                        },
                        "9": {
                            "type": "string"
                        },
                        "10": {
                            "type": "string"
                        },
                        "11": {
                            "type": "string"
                        }
                    },
                    "type": "object"
                },
                "Revision Date": {
                    "properties": {
                        "0": {
                            "type": "string"
                        },
                        "1": {
                            "type": "string"
                        },
                        "2": {
                            "type": "string"
                        },
                        "3": {
                            "type": "string"
                        },
                        "4": {
                            "type": "string"
                        },
                        "5": {
                            "type": "string"
                        },
                        "6": {
                            "type": "string"
                        },
                        "7": {
                            "type": "string"
                        },
                        "8": {
                            "type": "string"
                        },
                        "9": {
                            "type": "string"
                        },
                        "11": {
                            "type": "string"
                        },
                        "18": {
                            "type": "string"
                        }
                    },
                    "type": "object"
                }
            },
            "type": "object"
        }
    },
    "type": "object"
}

Alternatively, to get the values through expressions you can use <Name_Of_The_Action_You_Are_Retrieving_The_Object>?['body']?['<Object_Name>']?['<String_Name>'].

Example:

outputs('Compose')?['body']?['AP Outage Title']?['0']

Below is my logic app

enter image description here

RESULTS:

enter image description here

  • Related