Test your Liquid transformations without deployment

I work on a project doing integration with Azure Integration Services and Azure Functions. As always in integration projects doing mapping is a key area. I’m used from BizTalk development to be able to test my maps without doing deployment which makes it easy to develop in an iterative manner. While working with Logic Apps I started using Liquid transformations and did not find any tool to help with that. Logic Apps transforms with the DotLiquid library (C# Naming conventions). With that information in hand I created a program to test. I separated it in two a library, LiquidTransformationLib.dll, and a program, LiquidTransform.exe. The library makes it easy to use in automated tests.

Parameters for LiquidTransform.exe:

Parameter Description Required
-t | –template Full path to the Liquid template to use. Yes
-c | –content Full path to Content file. Yes
-d | –destination Full path to destination file. Will overwrite an existing file Yes
-r | –rootelement Root element to add before render. For Logic Apps you will need to use content No
-u | –rubynaming Use RubyNamingConvention, Logic Apps use C# naming conventions and will be the default. No
-? | -h | –help Show help information No

liquidtransformYou can download source code from the GiHub repo https://github.com/skastberg/LiquidTransformation

If just want the binaries https://github.com/skastberg/LiquidTransformation/tree/master/Binaries

More information about Liquid Transformation in Logic Apps:

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-enterprise-integration-liquid-transform

https://blogs.msdn.microsoft.com/logicapps/2017/12/06/introducing-the-liquid-connector-transform-json-to-json-json-to-text-xml-to-json-and-xml-to-text/

 

14 Comments

  1. Unknown's avatar

    This was a magic solution. I began my Liquid-journey for literally 1½ hour ago and came across this post.
    THANKS!
    This will save me tons of time compared to testing using Logic Apps.

    Reply

  2. Unknown's avatar

    Awesome!

    I’m however missing a custom filter that Logic Apps and API Management implements: “JSONArrayFor”.
    I’ve not yet found a source or repository for this. When running a template using the tag it will throw an error: “Unhandled Exception: DotLiquid.Exceptions.SyntaxException: Unknown tag ‘JSONArrayFor'”

    I am currently myself searching for the source for this custom filter but just wanted you to know.

    References:

    https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-enterprise-integration-liquid-transform?tabs=consumption#transform-xml-to-json

    https://dev.to/leonards/liquid-template-in-logic-app-4217

    Reply

  3. Unknown's avatar

    Hi Samuel, I am facing a strange issue. If I run the command without ”-r content” it runs fine and creates a JSON file but whenever I add ”-r content” as I need to use the liquid on logic apps it makes a file but will empty array nodes likes this ”[]”. Any ideas or suggestions, please?

    Reply

  4. Unknown's avatar

    Hi,
    We are using DotLiquid in APIM to transform SOAP to JSON. I’m keen to use your tool to test locally.

    .\LiquidTransform.exe -t “.\testDotLiquid.liquid” -c “.\OutageSearchByPostCodeResponse_soap.xml” -d “.\output.json”
    Unhandled Exception: Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
    at Newtonsoft.Json.JsonTextReader.ParseValue()
    at Newtonsoft.Json.JsonTextReader.Read()
    at Newtonsoft.Json.Linq.JObject.Load(JsonReader reader, JsonLoadSettings settings)
    at Newtonsoft.Json.Linq.JObject.Parse(String json, JsonLoadSettings settings)
    at LiquidTransformationLib.Transformer.RenderFromString(String content, String rootElement) in D:\a\LiquidTransformation\LiquidTransformation\code\LiquidTransformationLib\Transformer.cs:line 38
    at LiquidTransform.Program.Main(String[] args) in D:\a\LiquidTransformation\LiquidTransformation\code\LiquidTransform\Program.cs:line 26

    Seems (without looking at the code) like it might be trying to read the input content file as JSON? Is that the assumed input format? Might be worth noting that as a limitation if so.

    Thanks,
    Jason

    Reply

    1. Unknown's avatar

      Hi!
      Thanks for pointing out Jason!
      When I wrote the tool I aimed for testing transformations I did in Logic Apps. I intentionally left that out as I could not mimic and get the same result as Microsofts code. But you’re right, it should be pointed out. Please, feel free to contribute to the project in GitHub!

      Cheers
      Samuel

      Reply

Leave a reply to Using Liquid Template in Logic App – My Little Integration World Cancel reply