cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jef
Level: Powered On

Handling Null's in JSON

 

Hi all,

 

I've created a flow to get JSON data from a HTTP GET request. 

My JSON can contain NULL vallues, and the string type in JSON won't accept these null values. I tried to fix it with emtpy brackets:

     "displayName":  {},
     "givenName":  {}
 
The flow works perfectly, but when I try to add the flow in PowerApps I get the error: "Registering Error", because of the empty brackets instead of a datatype. 
Anyone knows how I can convert these nulls to empty strings in flow, or workaround this issue? 
 
my flow:

Untitled.png

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Jef
Level: Powered On

Re: Handling Null's in JSON

Hi, thanks for the reply.


I've fixed the problem by adding two 'initialize variable' components between the HTTP GET & the 'Parse JSON' component. 

 

- one that transforms the body of the http to string: string(body('HTTP'))

- one that replace the nulls in the string created in the step above:  replace(variables('varHTTPstring'), 'null', '""')

 

removenulls.png

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Handling Null's in JSON

Hi @Jef ,

 

I have made a test on my side and couldn't find the solution, I'm afraid that there is no any way to convert nulls to empty strings JSON in microsoft flow currently.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Jef
Level: Powered On

Re: Handling Null's in JSON

Hi, thanks for the reply.


I've fixed the problem by adding two 'initialize variable' components between the HTTP GET & the 'Parse JSON' component. 

 

- one that transforms the body of the http to string: string(body('HTTP'))

- one that replace the nulls in the string created in the step above:  replace(variables('varHTTPstring'), 'null', '""')

 

removenulls.png

View solution in original post

Helpful resources

Announcements
firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,817)