Hello, dear.

Tell me, how can one get rid of the exponent in Java when the number is output somewhere?

Let's say we have:

public static float testFloat2 = 0.0000000006F; 

Through GSON, I serialize this business, I get at the output:

 "testFloat2": 6.0E-10 

What can be done to display this:

 "testFloat2": 0.0000000006 
  • one
    read about the class Formatter - arg
  • I apologize, but how can I apply it directly to GSON? - Evgeny Karpov
  • Forgot to add. I serialize it like this: result.add (field.getName (), gson.toJsonTree (field.get (null), field.getType ())); either way (from a serializer of another class): result.add (field.getName (), context.serialize (field.get (category), field.getType ())); field I get a reflection. - Eugene Karpov
  • 2
    @ Yevgeny Karpov, ummm ... I do not understand, why do you need it? Json is just a data presentation format - yes, human-readable, so what? Why do you need readability of fields? - Barmaley
  • 2
    stackoverflow.com/questions/11119094/… here's a similar question with the answer - iksuy

1 answer 1

The answer is given in the comments to the question. I'm closing. Moder, please demolish this answer and close the question ...