Friday Fact: Parse JSON action input parameter (Content) supports the use of functions

Posted: May 10, 2024  |  Categories: Azure Logic Apps

When working with Logic Apps, it’s often necessary to employ conversion functions in the form of expressions. For example, you might need to convert XML to JSON and then parse that JSON.

Our first thought is to use this approach, which means you need to take extra action—this also means extra cost (a very small cost, but still extra cost)!

However, you can streamline the process by leveraging the conversion function directly within the Parse JSON action.

“But how do I figure out the schema for the Parse JSON?” you may wonder. Simple! Just send a request to the Logic App and get the outputs from the Compose action. (Of course, you can use an online converter, but for safety reasons and to protect your data, you can use this approach).

<ns0:UploadDocuments xmlns:ns0="
http://Example.Project.Schemas.Internal.DocumentsToUpload">
<Document>
<DocumentName>ServiceExchange.pdf</DocumentName>
<DocumentContent>
    JVBERi0xLjcNCiW1tbW1DQoxIDAgb2JqDQo8PC9U...
</DocumentContent>
</Document>
<Document>
<DocumentName>teste.pdf</DocumentName>
<DocumentContent>
    JVBERi0xLjcNCiW1tbW1DQoxIDAgb2JqDQo8PC9UeXBlL0NhdGFsb2c...
</DocumentContent>
</Document>
</ns0:UploadDocuments>

Once you’ve got the output of the transformation, ditch the Compose action.

Use the output to auto-generate a schema within the Parse JSON action.

Now, both the transformation and parsing happen simultaneously within the Parse JSON action.

It might not seem a lot, but when we are talking about long workflows it is better to mantain your Logic App with a clean and efficient flow, because even if it is a almost nothing, you still pay for every action you use.

To lazy to read? We’ve got you covered! Check out our video version of this content!

Hope you find this helpful! If you enjoyed the content or found it useful and wish to support our efforts to create more, you can contribute towards purchasing a Star Wars Lego for Sandro’s son!

Author: Luis Rigueira

Luis Rigueira is a Enterprise Integration Consultant at DevScope

Leave a Reply

Your email address will not be published. Required fields are marked *

turbo360

Back to Top