I have a case where I am getting an array of dictionary, and some of the items in the array are decimals that are in scientific notation. For example, I get 3.396929e+14 instead of 339692900000000. What would be the most efficient way to convert all numbers with scientific notation in any list of dictionaries into text so that they are readable in Appian?
It needs to work with any dictionary, so I cannot rely on consistent key value pairs.
Here is a real example of the data I am receiving. I have bolded some examples:
Discussion posts and replies are publicly visible
For this to work with any dictionary, you will be doing some json conversions. Here is a quick sample to get you going, re-using some code from Stefan in another thread on dictionary manipulation:
a!localVariables( local!data: { {field1: "value1asdf"}, {field2: "1.234e+10"}, {field3: "value3test"} }, reduce( updatecdt(_,_), cast('type!{http://www.appian.com/ae/types/2009}Dictionary', {}), a!forEach( items: local!data, expression: { a!localVariables( local!pair: split(a!toJson(fv!item),":"), local!key: stripwith(local!pair[1],"""{"), local!value: stripwith(local!pair[2],"""}"), a!fromJson( substitute( a!toJson( { p_l_a_c_e_h_o_l_d_e_r: if( search("e+",local!value)>0, rule!chris_test_convert_scientific_notation(value: local!value), local!value ) } ), "p_l_a_c_e_h_o_l_d_e_r", local!key ) ) ) } ) ) )
Helper rule!chris_test_convert_scientific_nocation(value [text]):
a!localVariables( local!split: split(ri!value,"e+"), local!count: len(split(local!split[1],".")[2]), concat( stripwith(local!split[1],"."), makerange(tointeger(local!split[2])-local!count,"0") ) )