【发布时间】:2018-03-01 23:58:37
【问题描述】:
我设法获得了 json rpc 请求的结果,如下所示:
{"id":1,"jsonrpc":"2.0","result":{"channels":[{"channel":"Channel A","channelid":2165,"label":"Channel A"},{"channel":"Channel B","channelid":748,"label":"Channel B"} 等
我想将响应解析为一个数组,在该数组中我可以在循环的每次迭代中读取通道、通道 ID 和标签。但没有设法得到它。
任何帮助将不胜感激。
抱歉没有编程经验,都是自学的
json rpc 请求代码:
String groupchannelsurl = "http://192.168.2.100:8080/jsonrpc?request={\"jsonrpc\": \"2.0\", \"method\": \"PVR.GetChannels\", \"params\": {\"channelgroupid\" : 9,\"properties\":[\"channel\"]}, \"id\": 1 }";
RequestQueue queue = Volley.newRequestQueue(this);
JsonObjectRequest getRequest = new JsonObjectRequest(Request.Method.GET, groupchannelsurl, null,
new Response.Listener<JSONObject>()
{
@Override
public void onResponse(JSONObject response) {
// display response
Log.d("Response", response.toString());
}
},
new Response.ErrorListener()
{
@Override
public void onErrorResponse(VolleyError error) {
Log.d("Error.Response", error.toString());
}
}
);
queue.add(getRequest);
【问题讨论】:
标签: java android json json-rpc