How to convert ArrayList to JSON object

前端 未结 5 768
遇见更好的自我
遇见更好的自我 2021-02-13 17:25
public ArrayList convertJsonToJsonObject(){

    ArrayList mylist = new ArrayList ();

    mylist.add(\"abc\");
    mylist.add(         


        
5条回答
  •  隐瞒了意图╮
    2021-02-13 17:51

    You can use the GSON library to accomplish this.

     ArrayList mylist = new ArrayList ();
     mylist.add("abc");
     mylist.add("cfd");
     mylist.add("ert");
     mylist.add("fg");
     mylist.add("ujk");
     String json = new Gson().toJson(mylist);
    

    You can refer to the GSON User Guide for more support.

提交回复
热议问题