Solved

JSONTemplater displaying floats values go long

  • 20 March 2019
  • 3 replies
  • 2 views

Badge +10

I am pushing data that I have cast as a double number to the JSONTemplater - it goes in as 0.09 once it comes out it gets longer becoming: "prod_index" : 0.09000000000000001

This seems like a floating point rounding number issue. Can anyone suggest a way around this.

Many Thanks,

Oliver

 

icon

Best answer by david_r 20 March 2019, 13:02

View original

3 replies

Userlevel 4

Try something like:

{
    "prod_index": fn:round(fme:get-attribute("prod_index"), 2)
}

 

Badge +10

Try something like:

{
    "prod_index": fn:round(fme:get-attribute("prod_index"), 2)
}

 

did the trick thank you, it is a pity those functions arent listed in the text editor functions list on the left hand side.

Userlevel 4

did the trick thank you, it is a pity those functions arent listed in the text editor functions list on the left hand side.

I agree. But you can find more information by googling for XQuery functions, e.g. "xquery round" etc.

Reply