Gson: Is there an easier way to serialize a map

前端 未结 5 2137
野趣味
野趣味 2020-11-28 04:36

This link from the Gson project seems to indicate that I would have to do something like the following for serializing a typed Map to JSON:

    public static         


        
5条回答
  •  失恋的感觉
    2020-11-28 05:29

    In Gson 2.7.2 it's as easy as

    Gson gson = new Gson();
    String serialized = gson.toJson(map);
    

提交回复
热议问题