【发布时间】:2018-08-18 17:38:06
【问题描述】:
我有一个 php 文件,其中 iam 使用不同的变量并将它们编码为对象,例如:-
$abc=array();
$abc['name']="Verma";
$bcd=array();
$bcd=['xyz']="Sharma";
echo json_encode($abc);
echo json encode($bcd);
现在在安卓中
当我使用响应侦听器时,如何分别解析这两个对象,我能够轻松地创建单个 json 对象,例如:-
final Response.Listener<String> resd= new Response.Listener<String>(){
@Override
public void onResponse(String response) {
try {
JSONObject ob= new JSONObject(response); // here how can i reffer to other json ojbect
String data=ob.getString("viki");
txt.setText(data);
} catch (JSONException e) {
AlertDialog.Builder j=new AlertDialog.Builder(MainActivity.this);
j.setCancelable(true);
j.setMessage(e.getMessage());
j.show();
}
}
};
【问题讨论】:
-
嗯,你可以从服务器返回json数组并在这里解析
-
这就是我要问的如何在android中解析jsonobjectarray
标签: php android json android-studio