Convert sting to Int

16 views
Skip to first unread message

Gihan Hanwella

unread,
Mar 14, 2025, 1:53:42 PMMar 14
to dotliquid
Hi Guys,
I'm trying to apply below liquid template in Azure Logc app. Basically I'm tying to add 2 values. But one of them is a in Text and the other is in Integer.

This woks if the source is like "IntegerData"77 but not when like  "IntegerData""77"

Ay idea how to get this to work? I used the "to_i" filter to convert to integer but that did not work. 

Thank you

Source JSON

{
    "content": {
        "TextData""44",
        "IntegerData""77"
    }
}

Liquid Map

{%- assign sum = 10 -%}
{%- assign sum  =  sum | Plus: content.IntegerData  -%}

{
  "add": {{sum}}
}


David Burg

unread,
Mar 16, 2025, 11:37:23 PMMar 16
to dotliquid
Implicit string to number conversions are supported in SyntaxCompatibility.DotLiquid21 but Logic App's DotLiquid version is too old for that.
"to_i" filter is not implemented in DotLiquid (yet).
As a workaround, you could host current DotLiquid version in an Azure Function and set the dot liquid compatibility flag to the latest.

Gihan

unread,
Apr 14, 2025, 10:32:55 PMApr 14
to dotl...@googlegroups.com
Thank you David.

I was able to fix the issue with the solution below. do you have any documentation on how to host current DotLiquid version in an Azure Function?? Thank you


{%- assign sum = 10 -%}
{%- assign temp =  content.IntegerData | Round  -%}  
{%- assign sum  =  sum | Plus: temp  -%}

{
  "add": {{sum}}
}

--
You received this message because you are subscribed to the Google Groups "dotliquid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dotliquid+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/dotliquid/5fb785c6-9f87-4153-a1da-20ba6d7ce51an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages