cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vnguyen1
Helper I
Helper I

how to output string value out of json parse ?

expressionevaluationfailed.PNGhi,

 

i have an issue to output a value . Example below is the output. I need to get the 1st media_type = ' image/jpeg" out of this. 

{
"images": [
{
"id": "875871070",
"download_sizes": [
{
"bytes": 69498,
"height": 416,
"media_type": "image/jpeg",
"name": "x_small",
"width": 416
},
{
"bytes": 109213,
"height": 594,
"media_type": "image/jpeg",
"name": "small",
"width": 594
},
{
"bytes": 375336,
"height": 1735,
"media_type": "image/jpeg",
"name": "medium",
"width": 1735
},
{
"bytes": 1255700,
"height": 4000,
"media_type": "image/jpeg",
"name": "large",
"width": 4000
},
{
"bytes": 12135563,
"height": 4000,
"media_type": "image/eps",
"name": "vector",
"width": 4000
}
]
}
],
"images_not_found": []
}

 

below is my json :

{
"type": "object",
"properties": {
"image": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"download_sizes": {
"type": "object",
"properties": {
"bytes": {
"type": "string"
},
"height": {
"type": "string"
},
"media_type": {
"type": "string"
},
"name": {
"type": "string"
},
"width": {
"type": "string"
}
}
}
}
}
}
}
}

 

this is the error message i got when trying to output the 'image/jpeg'  :

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('ParseFindMediaType')?['image']' is of type 'Null'. The result must be a valid array.

 

Please advice and thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @vnguyen1,

 

The property name in the Apply to each input should be body('Parse_JSON')?['images'], not body('Parse_JSON')?['image'], and the stcuture as below:

Screenshot 2021-02-24 142820.jpg

 

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.

View solution in original post

6 REPLIES 6
v-litu-msft
Community Support
Community Support

Hi @vnguyen1,

 

The property name in the Apply to each input should be body('Parse_JSON')?['images'], not body('Parse_JSON')?['image'], and the stcuture as below:

Screenshot 2021-02-24 142820.jpg

 

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.

View solution in original post

Thanks @v-litu-msft  for the response. however, i still got the same error message either (1) or (2). Please advice

 

vnguyen1_2-1614149401088.png

 

(1)

vnguyen1_3-1614149449826.png

 

(2)

 

vnguyen1_1-1614149309693.png

 

v-litu-msft
Community Support
Community Support

Hi @vnguyen1,

 

It is images, not image:

Screenshot 2021-02-24 142820.jpg

 

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.

vnguyen1
Helper I
Helper I

@v-litu-msft i got below error when update image to images in jason.Please advice

 

{
  "type""object",
  "properties": {
    "images": {
      "type""array",
      "items": {
        "images_not_found": {
          "type""object",
          "properties": {}
        },
        "type""object",
        "properties": {
          "id": {
            "type""string"
          },
          "download_sizes": {
            "type""object",
            "properties": {
              "bytes": {
                "type""string"
              },
              "height": {
                "type""string"
              },
              "media_type": {
                "type""string"
              },
              "name": {
                "type""string"
              },
              "width": {
                "type""string"
              }
            }
          }
        },
        "required": [
          "media_type",
          "id"
        ]
      }
    }
  }
}

 

vnguyen1_0-1614150181488.png

[
  {
    "message""Invalid type. Expected Object but got Array.",
    "lineNumber"0,
    "linePosition"0,
    "path""images[0].download_sizes",
    "schemaId""#/properties/images/items/properties/download_sizes",
    "errorType""type",
    "childErrors": []
  },
  {
    "message""Required properties are missing from object: media_type.",
    "lineNumber"0,
    "linePosition"0,
    "path""images[0]",
    "value": [
      "media_type"
    ],
    "schemaId""#/properties/images/items",
    "errorType""required",
    "childErrors": []
  }
]
vnguyen1
Helper I
Helper I

@v-litu-msft below is how i set it up and got the error in jason.Please advice

 

[
  {
    "message""Invalid type. Expected Object but got Array.",
    "lineNumber"0,
    "linePosition"0,
    "path""images[0].download_sizes",
    "schemaId""#/properties/images/items/properties/download_sizes",
    "errorType""type",
    "childErrors": []
  },
  {
    "message""Required properties are missing from object: media_type.",
    "lineNumber"0,
    "linePosition"0,
    "path""images[0]",
    "value": [
      "media_type"
    ],
    "schemaId""#/properties/images/items",
    "errorType""required",
    "childErrors": []
  }
]

vnguyen1_2-1614151098999.png

 

v-litu-msft
Community Support
Community Support

Hi @vnguyen1,

 

Please try to use the JSON schema:

{
    "type": "object",
    "properties": {
        "images": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "download_sizes": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "bytes": {
                                    "type": "integer"
                                },
                                "height": {
                                    "type": "integer"
                                },
                                "media_type": {
                                    "type": "string"
                                },
                                "name": {
                                    "type": "string"
                                },
                                "width": {
                                    "type": "integer"
                                }
                            },
                            "required": [
                                "bytes",
                                "height",
                                "media_type",
                                "name",
                                "width"
                            ]
                        }
                    }
                },
                "required": [
                    "id",
                    "download_sizes"
                ]
            }
        },
        "images_not_found": {
            "type": "array"
        }
    }
}

 

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.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

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

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Users online (2,188)