Creating JSON objects directly from model classes in Java

后端 未结 5 1618
一向
一向 2020-12-17 08:58

I have some model classes like Customer, Product, etc. in my project which have several fields and their setter-getter methods, I need to e

5条回答
  •  难免孤独
    2020-12-17 09:15

    Use gson to achieve this. You can use following code to get the json then

    Gson gson = new Gson();
    String json = gson.toJson(yourObject);
    

提交回复
热议问题