如何在Android的字符串的JSON数组 [英] how to create a Json array of strings in android
本文介绍了如何在Android的字符串的JSON数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个这样的数组 [stringone,stringtwo]
并把它传递到Web服务器。当我试图做一个字符串数组像的String [] = {stringone,stringtwo]
它很奇怪通过 {使它用户ID:[Ljava.lang.String; @ 406fe4b8}
我应该怎么来构建我的JSON数组如果不使用字符串数组
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 String[]={"stringone","stringtwo"]
it passed in something weird {"userids":"[Ljava.lang.String;@406fe4b8"}
how should I be constructing my JSON array if not by using string arrays?
感谢
推荐答案
如果你想创建 JSONArray
从列表
或数组,就可以使用构造,这需要收藏
:
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));
这篇关于如何在Android的字符串的JSON数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文