How to prevent Gson from converting a long number (a json string ) to scientific notation format?

If serializing to a String is an option for you, you can configure GSON to do so with:

GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.setLongSerializationPolicy( LongSerializationPolicy.STRING );
Gson gson = gsonBuilder.create();

This will produce something like:

{numbers : [ "268627104", "485677888", "506884800" ] }

Leave a Comment