Workflow expression function xml() behavior when converting numbers with decimal

This post has been republished via RSS; it originally appeared at: Microsoft Tech Community - Latest Blogs - .

The xml() expression function returns the XML version for a string that contains a JSON object.

 

Issue:

You might notice a floating-point precision issue when this function used to convert a string that contains a JSON object with decimal numbers as shown in the below sample.

Manohar_Patel_Seshapur_0-1656248648741.png

 

This is a known issue due to the below third party NewtonSoft package used by the function that exhibits this behavior. 

https://www.newtonsoft.com/json/help/html/M_Newtonsoft_Json_Linq_JToken_ToObject__1_1.htm

 

NewtonSoft loads the floating point numbers into .NET double type, which injects this precision loss when it serializes them back to string. Per default at https://www.newtonsoft.com/json/help/html/P_Newtonsoft_Json_JsonSerializerSettings_FloatParseHandling.htm

 

Workaround:

At the moment, you could workaround this behavior by providing the value as a string as shown in the below sample.

Manohar_Patel_Seshapur_2-1656248698473.png

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.