Gson. Deserialize integers as integers and not as doubles

后端 未结 7 1029
我寻月下人不归
我寻月下人不归 2020-12-09 16:46

I have json object with arbitary values inside. And I want to deserialize it in a Map. Everything is ok except converting integers to a doubles. See example:



        
相关标签:
7条回答
  • 2020-12-09 17:44

    There are no integer type in JSON. 1 and 1.0 are the same. You need to parse that 1.0 to 1 in your code. Or you need to map the JSON to some VO class and define the type of fields of the class explicitly , so that GSON can understand what you are looking for.

    0 讨论(0)
提交回复
热议问题