Trouble outputting Float value using Jackson library for Java

606 views Asked by At

When using Jackson to convert a pojo to a string I am finding that my Float values are being truncated 5852402.63111111 is becoming 5852402.6 when I print out the string. Also some of the values come with E7 or some number after them when they cannot be put into a value with 8 digits. Is there something that must be done with the printer or mapper to set it to not truncate my values. I have been looking through the documentation and have had no luck figuring this one out. Thanks!

Currently my method for converting to a string is:

    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    DefaultPrettyPrinter printer = new DefaultPrettyPrinter();
    mapper.writer(printer).writeValueAsString(myObject);
0

There are 0 answers