Share via


Parse Json - Null Values

Question

Friday, August 3, 2018 8:51 PM | 1 vote

Hello,

I'm connecting to a Function from Logic apps. My function is HTTP triggered and returns the following Json data:

{
  "Timestamp": "2018-08-03T20:25:56.5370025Z",
  "Value": 312.354,
  "Good": true
}

I'm using "Parse JSON" in logic apps. The "Value" property is normally a number but it could also be "null" meaning that the value is "bad". I figured that I have to add the null type in the parse JSON schema otherwise the parser fails when there is null values. I did the following in the schema:

"Value": {

"type": [

"number",

"null"

]

After adding the Value - null type to the schema "Value" stop showing up in the

dynamic Content window.



So, my json input has 3 properties Good, Timestamp and Value. After adding the "null"

type to the Json parser schema I do not see Value in the Dynamic Content window.

If I remove the null type from the schema then I can see it again.

How could I see the value in the Dynamic Content window after adding the null

type to the schema?

Thanks!

 

All replies (5)

Saturday, August 4, 2018 4:27 AM ✅Answered | 1 vote

I think it is just a visual issue because maybe designer is not recognizing nulls. Something Microsoft can look into. However, this is not stopping you to use this field with nulls; 

I did a small POC and observed this behavior too but it works as because underlying workflow definition language recognizes nulls so don't worry.

You can use the required field in 2 ways; 

Option 1: Directly write this in your action 

@{body('Parse_JSON')?['age']}

**Option 2 **

1.
Alternatively, please do this;
You can just define the field without the null in the schema and when you see it, you can drag it in your next Step. 2. After that, you can just update the schema back to add "null" and it will work

**Mark it as Answer **OR **Please Vote as Helpful **by clicking the upward arrow mark


Tuesday, August 7, 2018 4:29 PM

Thanks.

I had tried option 1 before and it works fine. I was wondering if I did something wrong in the JSON schema definition but looks it's a bug that Microsoft may need to fix. 

As mentioned before, I'm doing a post request to my Function in Logic apps and it returns the output as shown in the image below. Then I have to use the Json Parser to be able to get each of the attributes in the output. Is there a way to make my Function to return the output already parsed so I don't have to use the json parser after I call the function? I have seen some other logic app connectors capable of doing that. Oracle - Get rows is an example where you don't necessary need to add the Json parser step after it to be able to extract the table's column values.   

 

Thanks!


Tuesday, August 7, 2018 5:07 PM

you don't need to add parser for most of the connectors. you can just use the code as it is 

See in below I just left a placeholder for the Connector Name and you can just replace with the any connector 

@{body('Connector Name')?['age']}

Tuesday, August 7, 2018 8:56 PM

I'm trying to avoid the need to enter code as much as possible in the logic app. I'm trying to build a custom connector that more people in my company will be using. Unfortunately not everybody is into coding, and if I'm able to display in the "Dynamic Content" window the different properties from the Json output it is going to be more easy for them. I'm trying to give them more the experience of "drag and drop" vs coding. So far, my custom connector displays only the "body" property as output in the dynamic window.

  


Monday, October 21, 2019 3:09 AM

Hi - I have exactly the same problem, and so it seems that this issue has continued for 1 year.  How do we get Microsoft to fix this? The only way I can raise a case is to have an Azure support agreement (which we don't) but this seems like a bug rather than a how-to question.  How can we report this as a bug so it gets looked at?

I know there are workarounds, but it would make life so much easier if you could Parse JSON whilst handling null values and still ending up with dynamic content output that you can use in following cards.  

Thanks