我有以下 Android java 代码:
String json = "{\"Name_1\":1,\"Name_2\":0,\"Name_3\":0}";
JSONObject object = new JSONObject(json);
String[] propertyNames = JSONObject.getNames(object);
values = new String[propertyNames.length];
for (int i = 0; i < propertyNames.length; i++) {
values[i] = String.valueOf(object.get(propertyNames[i]));
}
但我收到以下错误:该方法getNames(JSONObject)
未定义类型JSONObject
。我该怎么做才能得到propertyNames
?