Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logic app read property of json stored in variable

I have this json in a Logic App variable. I want to 'id' property of this JSON and use further. How to get this id property value?

My json is:

{
"id": 1,
"name": "John bright",
"username": "Lily",
"email": "[email protected]",
}
like image 351
dotnetavalanche Avatar asked May 21 '19 18:05

dotnetavalanche


People also ask

What is parse JSON?

JSON parsing is the process of converting a JSON object in text format to a Javascript object that can be used inside a program. In Javascript, the standard way to do this is by using the method JSON.


2 Answers

You said your json is a variable, but you don't mention which type it's stored.

  1. Stored as string. In this way the whole json is a string, it's not supported to select property. So you need parse it to Json with Parse JSON action then you will be able to select property. About the Parse JSON Schema, just click the Use sample payload to generate schema and paste your json value, it will generate. And select your property just use the @{body('Parse_JSON')?['name']}, it will work.

enter image description here

enter image description here

  1. If it's stored as an Object, it will be easier to do it, just use expression variables('test1')['name'] to get it.

enter image description here

enter image description here

like image 68
George Chen Avatar answered Nov 15 '22 04:11

George Chen


Use the Parse Json action and use your payload as a "Use sample payload to generate schema". After that, id will be listed as a Dynamic content from the Parse Json action.

like image 21
AdAstra Avatar answered Nov 15 '22 02:11

AdAstra