Skip to main content

I am converting ESRI gdb tables to Josn format(text_line), but unfortunately few of attribute values are given extra/unnecessary precision?

data from tables : "aos" : 105.20 ,"aos" : 293.22

output generated : "aos" : 105.20999999999999, "aos" : 293.22000000000003

To avoid this I have used attribute rounder , but no use, client required only 2 digits after (it should be float) . could some one help to resolve this issue on this.

I have used the below transformers

  1. gdb reader
  2. attribute manager and attribute rounder
  3. Josn templater
  4. Text file writer (text_line)

Thanks in advance

Chandra Sekhar Guda

 

 

Since you're going to text, the StringFormatter is probably the best way to go, using .2f as the format string should do the trick.


If you want to keep "aos" as a proper floating point value in the JSON, try using fn:round() in the expression of the JSONTemplater, e.g.

"aos": fn:round(fme:get-attribute("my_aos_attribute"), 2)

This will round "my_aos_attribute" to the nearest 2 decimal places and output it as "aos".


If you want to keep "aos" as a proper floating point value in the JSON, try using fn:round() in the expression of the JSONTemplater, e.g.

"aos": fn:round(fme:get-attribute("my_aos_attribute"), 2)

This will round "my_aos_attribute" to the nearest 2 decimal places and output it as "aos".

Thank you very much David_r, it worked, great


If you want to keep "aos" as a proper floating point value in the JSON, try using fn:round() in the expression of the JSONTemplater, e.g.

"aos": fn:round(fme:get-attribute("my_aos_attribute"), 2)

This will round "my_aos_attribute" to the nearest 2 decimal places and output it as "aos".

thanks, @david_r​ 

You saved my day!


gold! thank you for the question and answer!


Reply