cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mokhawaja
Level 8

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
mokhawaja
Level 8

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:
Screenshot (24).pngopen the attachment

 

Screenshot (25).pngclick ok

 

Screenshot (26).pngwala...

 

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
Community Support Team
Community Support Team

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.
mokhawaja
Level 8

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 

mokhawaja
Level 8

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:
Screenshot (24).pngopen the attachment

 

Screenshot (25).pngclick ok

 

Screenshot (26).pngwala...

 

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
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!

Users Online
Currently online: 333 members 5,410 guests
Please welcome our newest community members: