Forum Discussion
Logic Apps Data Mapper Integer Formatting Issue
Hello team, I am working on a data map that is giving me a hard time in the logic app. For my transformations, I do json-to-json transformation using the new data mapper. I have managed to handle all fields but for some reason one integer field is giving me a very hard time.
<number key="id">
<xsl:value-of select="/*/*[@key='mapparameters']/*[@key='counterpartyType1id']" />
</number>
Here, if I pass let's say 12345, I want to see 12345 but the result is 12345.0. This action's output is directly being sent to a HTTP call in the logic app and based on the workflow run logs, everything seems okay. In the logs, the value seen as 12345. However, when we check the backend, this field is 12345.0 in the request body and this causes an error as the application does not accept it.
I tried to format the number and convert it in any way but with no luck, the issue is this problem started happening out of the blue someday.
Does anyone can guide me a potential resolution? Thanks.
1 Reply
This behavior is expected. Within Logic Apps, the Data Mapper interprets numeric values as floating‑point numbers during JSON transformations. Consequently, an integer such as 12345 is serialized as 12345.0. To ensure the value is preserved as an integer, you must explicitly apply formatting or type conversion using the Data Mapper’s utility functions (for example, format-number() or toInteger()), thereby guaranteeing the output is handled as an integer rather than a floating‑point value.
https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-schema