how to create a Json array of strings in android

前端 未结 2 389
滥情空心
滥情空心 2021-01-23 04:59

I am trying to create an array like this [\"stringone\",\"stringtwo\"] and pass it to the webserver. When I tried doing making it with a string array like Str

相关标签:
2条回答
  • 2021-01-23 05:36

    If you want to create JSONArray from List or array, you can use constructor, which takes Collection:

    String[] data = {"stringone", "stringtwo"};
    JSONArray json = new JSONArray(Arrays.asList(data));
    
    0 讨论(0)
  • 2021-01-23 05:36

    The easiest way is to create a JSONArray object and use the put method(s) to add any Strings you want. To output the result, just use the toString() method.

    0 讨论(0)
提交回复
热议问题