cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Foxxx
Frequent Visitor

Save HTTP Get Body to file and keeping structure / layout

Hi all,

 

I'm trying to save the HTTP body output to a file, but by keeping the original layout.

 

The original layout / structure:

{
  "facts": [
    {
      "Productgroep""Benzines",
      "Product""Benzine 95 RON E10 (€/L)",
      "Dag""31mei22",
      "Prijs excl. BTW"1.666900000000006,
      "Prijswijziging excl. BTW"null,
      "Prijs incl. BTW"2.017000000000007,
      "Prijswijziging incl. BTW"null
    },
 
What I get when the file is saved:
{"facts":[{"Productgroep":"Benzines","Product":"Benzine 95 RON E10 (€/L)","Dag":"31mei22","Prijs excl. BTW":1.666900000000006,"Prijswijziging excl. BTW":null,"Prijs incl. BTW":2.017000000000007,"Prijswijziging incl. BTW":null},
 
So does somebody know how you can save a JSON file and keeping the layout?
I've already tried to first convert the HTTP body to JSON in the flow itself and then saving the JSON output. But with no succes.
1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Foxxx ,

 

When converting array or Object to JSON strings in flow, the format of newline and indentation is not preserved. But I have an alternative that can at least implement line breaks to make JSON strings easier to read. I've made a test for your reference:

 

vbofengmsft_0-1654137693027.jpeg

 

Expression for your reference:

 

replace(
replace(
replace(
string(variables('TheJSONValue')),
'{',
concat(decodeUriComponent('%0A'),'{',decodeUriComponent('%0A'))
),
'}',
concat(decodeUriComponent('%0A'),'}',decodeUriComponent('%0A'))
),
',',
concat(',',decodeUriComponent('%0A'))
)

 

Result:

vbofengmsft_1-1654137728898.jpeg

Best Regards,

Bof

 

 

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @Foxxx ,

 

When converting array or Object to JSON strings in flow, the format of newline and indentation is not preserved. But I have an alternative that can at least implement line breaks to make JSON strings easier to read. I've made a test for your reference:

 

vbofengmsft_0-1654137693027.jpeg

 

Expression for your reference:

 

replace(
replace(
replace(
string(variables('TheJSONValue')),
'{',
concat(decodeUriComponent('%0A'),'{',decodeUriComponent('%0A'))
),
'}',
concat(decodeUriComponent('%0A'),'}',decodeUriComponent('%0A'))
),
',',
concat(',',decodeUriComponent('%0A'))
)

 

Result:

vbofengmsft_1-1654137728898.jpeg

Best Regards,

Bof

 

 

Foxxx
Frequent Visitor

Thanks  v-bofeng-msft! Works like a charm 😀

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,331)