我正在检索 JSON 数据并将其存储在数组中以供使用。
我通过以下方式获取 json 数据:-
Uri uri = new Uri.Builder().scheme("http").authority().path().build();
System.out.println("uri of category is : -"+uri);
URI u = new URI(uri.toString());
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(u);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
is = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is),8);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line="0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
但我的 json 是其他类型。所以我很困惑如何获取和存储在我的数组列表中。
{
employee: [
{
name: "ajay",
id: 1,
},
{
name: "rajiv",
id: 2,
}
],
address: [
{
city: "bombay",
pin: 114141
}
]
}
我知道有第一个 JSONObject 并且有两个 jsonarray。但我怎样才能找回它。