web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / XML to JSON convert tr...
Power Automate
Unanswered

XML to JSON convert trouble

(0) ShareShare
ReportReport
Posted on by

Hi everybody,

 

I want to get exchange rates from Sweden Central Bank with API and insert them about D365 entity. 

I connect the API as below.

I got the connection results from API as xml.

Xml results are as follows:

image.png

 

Then, I tried to convert results to JSON from XML using Compose action within json() expression.

 

json(xml(body('HTTP')))

 

image.png

I tried to extract results with Parse JSON action as follow: 

 

image.png

I try to get the result as below but because of @xmlns it gives "#text": "<data>" the data I need.

 

{
 "?xml": {
 "@version": "1.0",
 "@encoding": "UTF-8"
 },
 "SOAP-ENV:Envelope": {
 "@xmlns:SOAP-ENV": "http://www.w3.org/2003/05/soap-envelope",
 "SOAP-ENV:Body": {
 "ns0:getMonthlyAverageExchangeRatesResponse": {
 "@xmlns:ns0": "http://swea.riksbank.se/xsd",
 "return": {
 "@xmlns": "",
 "datefrom": {
 "@xmlns": "",
 "#text": "2020-11-02"
 },
 "dateto": {
 "@xmlns": "",
 "#text": "2020-11-30"
 },
 "informationtext": {
 "@xmlns": "",
 "#text": "Averages are calculated on published observations for the daily fixing rates. \r\n\r\nObservations are published daily at 12.15 p.m."
 },
 "groups": {
 "@xmlns": "",
 "groupid": {
 "@xmlns": "",
 "#text": "130"
 },
 "groupname": {
 "@xmlns": "",
 "#text": "Currencies against Swedish kronor"
 },
 "series": [
 {
 "@xmlns": "",
 "seriesid": {
 "@xmlns": "",
 "#text": "SEKAUDPMI"
 },
 "seriesname": {
 "@xmlns": "",
 "#text": "AUD"
 },
 "unit": {
 "@xmlns": "",
 "#text": "1.0E0"
 },
 "resultrows": {
 "@xmlns": "",
 "period": {
 "@xmlns": "",
 "#text": "2020 November"
 },
 "min": {
 "@xmlns": "",
 "#text": "6.2465E0"
 },
 "average": {
 "@xmlns": "",
 "#text": "6.2861E0"
 },
 "max": {
 "@xmlns": "",
 "#text": "6.3272E0"
 },
 "ultimo": {
 "@xmlns": "",
 "#text": "6.2627E0"
 }
 }
 },

 

What I want here is that there should not be @xmlns and "#text" objects in the result.

I want the results to be directly against the relevant objects: 

 

"seriesid":"SEKAUDPMI",
"seriesname":"AUD",
"unit": "1.0E0",

 

What method can I use to get the format I need? 

 

Categories:
I have the same question (0)
  • v-litu-msft Profile Picture
    on at

    Hi @Anonymous,

     

    You could initialize an array variable to store the array of series, then append the restructured data into the array:

    Screenshot 2020-12-23 103736.jpg

     

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

  • Community Power Platform Member Profile Picture
    on at

    Hi @v-litu-msft,

     

    I tried your solution as below:

    Omer_Orhan_0-1608722005298.png

     

    I run it but I didn't get solution I wanted.

    I still got the object I didn't want following,

    image.png

    Should I apply the solution in a different section or should your solution be implemented when converting HTTP result to JSON? 

    Omer_Orhan_0-1608724638154.png

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard