我有一个JSONArray,它存储以下内容:
[
"7d92a26dddcbd95c876479cf97afa404.jpg/500/500/0",
"2efb1955602498c0a82fd5c6f9611d0a.png/500/500/0",
"53633e49bc1a7725cf28cdbfbcd3f03b.jpg/500/500/0"
]
如何在JSONArray中获取字符串?我尝试jaImage.getString(0);
但发生了java.lang.NullPointerException
异常。
以下是我的代码:
for(int i = 0; i < jsonArrayStore.length(); i++)
{
try
{
JSONArray jaImage = jsonObjectStore[i].getJSONArray("images");
if(jaImage == null)
{
Log.v("jaImage", "null");
}
else
Log.v("jaImage", jaImage.toString());
imgName[i] = new String[jaImage.length()];
Bitmap sto_image;
for (int j = 0; j < jaImage.length(); j++)
{
String image = jaImage.getString(j);
Log.v("jaImage", image);
}
}
catch (Exception e)
{
Log.v("JSONArray jaImage Error", e.toString());
}
}
修改
下面是我的logcat:
06-29 03:02:48.301 24594-24618/mobile.howddy.com.howddymobile V/jaImage﹕ ["7d92a26dddcbd95c876479cf97afa404.jpg\/500\/500\/0","2efb1955602498c0a82fd5c6f9611d0a.png\/500\/500\/0","53633e49bc1a7725cf28cdbfbcd3f03b.jpg\/500\/500\/0"]
06-29 03:02:48.301 24594-24618/mobile.howddy.com.howddymobile V/JSONArray jaImage Error﹕ java.lang.NullPointerException
06-29 03:02:48.301 24594-24618/mobile.howddy.com.howddymobile V/jaImage﹕ ["29778c73baca5d56d5a42c510cc5ae2e.png\/500\/500\/0","a35493d3aa674000566bfc3ef1053fcb.jpg\/500\/500\/0","a5fce41943837ba92f01a0b47aeb1054.jpg\/500\/500\/0"]
06-29 03:02:48.301 24594-24618/mobile.howddy.com.howddymobile V/JSONArray jaImage Error﹕ java.lang.NullPointerException
06-29 03:02:48.301 24594-24618/mobile.howddy.com.howddymobile V/jaImage﹕ ["e308cc58d082906d936a23eae4bc4708.jpg\/500\/500\/0","ab9ce8cadcc379582210d4b65bda9ef7.jpg\/500\/500\/0","867a82d768deff21dfcb9cd988a26d58.jpg\/500\/500\/0","72df45688fe4a70b6c0b1db2d2a2533e.jpg\/500\/500\/0"]
06-29 03:02:48.301 24594-24618/mobile.howddy.com.howddymobile V/JSONArray jaImage Error﹕ java.lang.NullPointerException