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

前端 未结 7 2179
予麋鹿
予麋鹿 2020-11-29 06:14

I need to convert json string to java object and display it as a long. The json string is a fixed array of long numbers:

{numbers
[ 268627104, 485677888, 506         


        
7条回答
  •  时光说笑
    2020-11-29 06:18

    We can use the below code solution for number Long:

    Document doc = documentCursor.next();  
    
    JsonWriterSettings relaxed = JsonWriterSettings.builder().outputMode(JsonMode.RELAXED).build();  
    
    CustomeObject obj = gson.fromJson(doc.toJson(relaxed), CustomeObject.class);
    

提交回复
热议问题