Hi in my project i need to create a JSONArray type with the GSON class
{
\"message\": [
\"msg 1\",
\"msg 2\",
\"msg 3\"
],
\"asec\": [
public class ArrayBean {
ArrayList message = new ArrayList();
ArrayList asec = new ArrayList();
}
create bean class above arraybean, then u can add the values on your main class and print the output.
Gson gson = new Gson();
ArrayBean arrayBean = new ArrayBean();
arrayBean.message.add("msg 1");
arrayBean.message.add("msg 2");
arrayBean.message.add("msg 3");
arrayBean.asec.add("asec 1");
arrayBean.asec.add("asec 2");
arrayBean.asec.add("asec 3");
Log.d("rvg",""+gson.toJson(arrayBean));