Azure Functions | Liquid | c#

Abhay Chandramouli 1,051 Reputation points
2023-06-27T14:13:34.3333333+00:00

Hi

I am making an api call from Azure Functions, and receieve a response in JSON.

Now I need to transform this JSON to a completely different JSON structure.

I would love to use liquid as in logic apps. Please let me know if there is any way to achieve this ?

or what other way is recommended.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,701 questions
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,896 Reputation points
    2023-06-29T07:11:15.8633333+00:00

    @Abhay Chandramouli Thanks for reaching out. Can you confirm in which language you have created your function app?

    As your using dotnet then I will suggest you to leverage the dotliquid

    You can simply add the Install the DotLiquid package in your Azure Functions project. You can do this by adding this to your csproj file or add the nuget package.

    For your reference sharing the steps:

    Leverage new LiquidTemplate object and pass in the JSON data as a string. You can do this using the following code:

    var template = Template.Parse(jsonString);
    

    Create a new Hash object and add any variables that you want to use in your Liquid template. You can do this using the following code:

    var hash = new Hash();
    hash.Add("variable1", "value1");
    hash.Add("variable2", "value2");
    

    Render the Liquid template using the Render method and passing in the Hash object. You can do this using the following code:

    var result = template.Render(hash);
    

    The result variable will contain the transformed JSON data. In case if you need any help with the SDK then you can reach out to the out to them over them over here

    If you need any assistance with Azure function then please let me know.

    Please "Accept Answer" if the answer is helpful so that it can help others in the community.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.