airmoi

Another decimal point issue with JSON function

Discussion created by airmoi on Jun 1, 2017
Latest reply on Aug 18, 2017 by TSGal

As explained in a previous post here Data API decimal separator issue with Tableau (and everything else...) , json standard defines "." as the decimal separator.

 

When using JsonSetElement on a comma based system, the number is converted properly in the json string.

Unfortunately, when you try to get back that value,  using JsonGetElement, value is returned as is, with a "." decimal separator, leading to errors and inconsistent datas...

 

Here is a concrete example you may test in a  data viewer :

Let ( [

  _MyNumber = 2,5;

  _MyJson = JSONSetElement ( "{}" ; "MyNumber" ; _MyNumber ; JSONNumber )

];

"MyJson = " & _MyJson

& ¶ & "MyNumber = " & _MyNumber

& ¶ & "Json Number returned = " & JSONGetElement ( _MyJson ; "MyNumber" )

)

 

It returns :

MyJson = {"MyNumber":2.5}

MyNumber = 2,5

Json Number returned = 2.5 <== not a correct number for a comma based system !!

Outcomes