How do I prevent number format changes in liquid transforms?

Kaustubh Badrike 1 Reputation point
2020-06-12T15:44:24.517+00:00

I have the following logic app definition

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "JSONToJSON1": {
                "inputs": {
                    "content": "@triggerBody()",
                    "integrationAccount": {
                        "map": {
                            "name": "48995ebf-6578-44fe-b32f-e5600bc3deb8.liquid"
                        }
                    }
                },
                "kind": "JsonToJson",
                "runAfter": {},
                "type": "Liquid"
            },
            "Response1": {
                "inputs": {
                    "body": "@body('JSONToJSON1')",
                    "headers": {},
                    "statuscode": 200
                },
                "kind": "Http",
                "runAfter": {
                    "JSONToJSON1": [
                        "Succeeded"
                    ]
                },
                "type": "Response"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            },
            "FunctionAppName": {
                "defaultValue": "",
                "type": "String"
            },
            "ResourceGroupName": {
                "defaultValue": "",
                "type": "String"
            },
            "SubscriptionId": {
                "defaultValue": "",
                "type": "String"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    }
}
  1. Case 1:
    When the content of 48995ebf-6578-44fe-b32f-e5600bc3deb8.liquid is {"target":{{content.source}}}

and the POST body to my trigger is

{
    "source":12345671010.89
}

the response returns the number property "target" as a round (uncertain) of what I sent in property "source" (see below)

{
    "target": 12345670000.0
}
  1. Case 2:
    When the content of 48995ebf-6578-44fe-b32f-e5600bc3deb8.liquid is {"target":"{{content.source}}"}

and the POST body to my trigger is

{
    "source":12345671010.89
}

the response returns the number in string property "target" as the non-precise scientific notation of what I sent in property "source" (see below)

{
    "target": "1.234567E+10"
}

In both cases, the expected behaviour is that the property "target" should receive the value of the property "source" as sent in the trigger body.
How should I modify my logic app to achieve this?

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,004 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. David Burg - MSFT 11 Reputation points
    2020-06-26T05:37:48.953+00:00

    We have been rolling out changes to underlying DotLiquid open-source implementation and the Azure Logic Apps Json to Liquid 'Drop' conversion so that 64 bit integers as well as Decimal / Double precision floating number types are used whenever required for either value extend or precision. A few sovereign cloud regions remain to be updated.

    You can find information about the maximum range for which we can use Decimal, and when this range is exceeding we have to fallback to double precision floating type (with a loss in precision) here:

    https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types#characteristics-of-the-floating-point-types

    Integer of large or very small value go to Int64 aka long, which maximum range is described here:

    https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types#characteristics-of-the-integral-types

    If you find a handling of values that is not conforming to these specifications, consider raising a free support ticket in the Azure management portal.

    0 comments No comments