从JSON对象的Android获取字符串值
问题描述:
我Begineer在Android.In我的项目,我从HTTP响应收到下面的JSON。
I am Begineer in Android.In my Project, I am getting the Following json from the HTTP Response.
[{"Date":"2012-1-4T00:00:00","keywords":null,"NeededString":"this is the sample string I am needed for my project","others":"not needed"}]
我想从上面json.How的NeededString得到它。
I want to get the "NeededString" from the above json.How to get it.
答
这可能会帮助你。
JSONArray arr = new JSONArray(result);
JSONObject jObj = arr.getJSONObject(0);
String date = jObj.getString("NeededString");