How to serialize Object to JSON?

前端 未结 7 1679
面向向阳花
面向向阳花 2020-11-27 05:49

I need to serialize some objects to a JSON and send to a WebService. How can I do it using the org.json library? Or I\'ll have to use another one? Here is the class I need t

7条回答
  •  眼角桃花
    2020-11-27 05:57

    Easy way to do it without annotations is to use Gson library

    Simple as that:

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

提交回复
热议问题