cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Collector
Kudo Collector

convert json output into xml

Hi,

is there a way to convert a json array output into an xml?

 

Regards,

Mohammad

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Kudo Collector
Kudo Collector

Re: convert json output into xml

Hi,

Finally I am successful to convert json to xml file and send it as attachment, (but unfortunately it is very slow, as it should convert every item alone then recombine them back)... here it is:

 

to explain why I needed xml, bacause it can deal with unicode data (i am using Arabic language in my data), so when I tried to export the data and save it as csv file, the unicode would be scrmbled like this

Screenshot (16).png

then I saw that there is a function that can convert json to xml, but discovered that it can only deal with json objects, and not arrays! 

And with the inspiration from @sergeluca's blog of converting csv to json, (which I learnt a lot from about compose action and variables) i succeeded to convert the json output from execute SQL query action to xml file saved as *.xls, which will open in excel directly.

So the magic is done using 4 compose actions: the first two compose actions inside an apply to each loop to convert each json object to xml format, then the 3rd will join all results from the apply to each using 

join(outputs('Compose_2'), '')
then the fourth compose action the add the xml "header"... check the screenshots:Screenshot (12).png

 

Screenshot (13).png

 

Screenshot (14).png

 

Screenshot (15).png

 

Then here when i recieve the file:
open the attachmentopen the attachment

 

click okclick ok

 

wala...wala...

 

but the main problem is the long duration for the execution of the flow espcially for large data sets! so it would be really great if Microsoft find a direct way to convert json to xml... or at least support unicode in csv creation!!
 
Thanks,
Mohammad

View solution in original post

3 REPLIES 3
Highlighted
Community Support
Community Support

Re: convert json output into xml

Hi @mokhawaja,

 

I am afraid that currently it is not possible to convert JSON output into XML directly using Microsoft Flow. Please submit a request on Flow Ideas Forum about this issue:

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

I will suggest other customers who have the same request to vote your idea at here.

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Kudo Collector
Kudo Collector

Re: convert json output into xml

Hi @v-yamao-msft,

thanks for your reply... actually i was "partially successful" with some expressions, check the screenshot:

Screenshot (78).pngScreenshot (79).png

i was trying this so the file would open in excel.

actually i tried this option to solve the unicode problem that i faced previously, check it here:

https://powerusers.microsoft.com/t5/General-Flow-Discussion/save-as-csv-does-not-recognize-unicode-o...

 

i refered to this reference too:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#x...

 

thanks,

Mohammad 

Highlighted
Kudo Collector
Kudo Collector

Re: convert json output into xml

Hi,

Finally I am successful to convert json to xml file and send it as attachment, (but unfortunately it is very slow, as it should convert every item alone then recombine them back)... here it is:

 

to explain why I needed xml, bacause it can deal with unicode data (i am using Arabic language in my data), so when I tried to export the data and save it as csv file, the unicode would be scrmbled like this

Screenshot (16).png

then I saw that there is a function that can convert json to xml, but discovered that it can only deal with json objects, and not arrays! 

And with the inspiration from @sergeluca's blog of converting csv to json, (which I learnt a lot from about compose action and variables) i succeeded to convert the json output from execute SQL query action to xml file saved as *.xls, which will open in excel directly.

So the magic is done using 4 compose actions: the first two compose actions inside an apply to each loop to convert each json object to xml format, then the 3rd will join all results from the apply to each using 

join(outputs('Compose_2'), '')
then the fourth compose action the add the xml "header"... check the screenshots:Screenshot (12).png

 

Screenshot (13).png

 

Screenshot (14).png

 

Screenshot (15).png

 

Then here when i recieve the file:
open the attachmentopen the attachment

 

click okclick ok

 

wala...wala...

 

but the main problem is the long duration for the execution of the flow espcially for large data sets! so it would be really great if Microsoft find a direct way to convert json to xml... or at least support unicode in csv creation!!
 
Thanks,
Mohammad

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

Top Solution Authors
Top Kudoed Authors
Users online (11,395)