Please help me how to get the value of xy i have tried the code below but its not working. Is my code below wrong? Please help me. Thanks in advance
Json example below
{"name":"room ko","lights":["3","2"],"type":"Room","state":{"all_on":true,"any_on":true},"recycle":false,"class":"Living room","action":{"on":true,"bri":254,"hue":34704,"sat":198,"effect":"none","xy":[0.3228,0.3291],"ct":167,"alert":"none","colormode":"xy"}
Here the code I have tried so far.
String message="";
JSONArray jsonArray = null;
try {
JSONObject jsonObject = new JSONObject(s);
message = jsonObject.getString("name");
jsonArray = jsonObject.getJSONArray("xy");
Log.d(TAG,jsonArray);//error in here
} catch (JSONException e) {
e.printStackTrace();
}
我想你想:
jsonArray = jsonObject.getJSONObject("action").getJSONArray("xy");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.