java – Gson. Deserialize an integer to an integer instead of double

I have JSON objects with arbitrary values I want to deserialize it in the map Everything is fine except converting integers to doubles See example:

{"id":1,"inner_obj":{"key":"value","num":666,"map":{"key":"value"}}}

Deserialization (map. Tostring()):

{id=1.0,inner_obj={key=value,num=666.0,map={key=value}}}

Is there any simple way to deserialize "Id" and "num" as integers instead of doubles?

Solution

Jackson is better at detecting map types than gson: https://github.com/FasterXML/jackson-databind It's much easier

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>