We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一直报错 JSONReader reader = new JSONReader(new InputStreamReader(getAssets().open("goods.json"), "UTF-8")); reader.startArray();//开始解析json数组 while (reader.hasNext()) { reader.startObject();//开始解析json对象 Good good = new Good(); while (reader.hasNext()) { String key = reader.readString(); if ("id".equals(key)) { good.setId(reader.readString()); } else if ("name".equals(key)) { good.setName(reader.readString()); } else if ("price".equals(key)) { good.setPrice(Double.parseDouble(reader.readString())); } else if ("barCode".equals(key)) { good.setBarCode(reader.readString()); } else if ("desc".equals(key)) { good.setDesc(reader.readString()); } else if ("count".equals(key)) { good.setCount(Integer.parseInt(reader.readString())); } else { reader.readObject();//读取对象 } } reader.endObject();//结束解析对象 } reader.endArray();//结束解析数组 reader.close();关闭流 reader = null;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
一直报错
JSONReader reader = new JSONReader(new InputStreamReader(getAssets().open("goods.json"),
"UTF-8"));
reader.startArray();//开始解析json数组
while (reader.hasNext()) {
reader.startObject();//开始解析json对象
Good good = new Good();
while (reader.hasNext()) {
String key = reader.readString();
if ("id".equals(key)) {
good.setId(reader.readString());
} else if ("name".equals(key)) {
good.setName(reader.readString());
} else if ("price".equals(key)) {
good.setPrice(Double.parseDouble(reader.readString()));
} else if ("barCode".equals(key)) {
good.setBarCode(reader.readString());
} else if ("desc".equals(key)) {
good.setDesc(reader.readString());
} else if ("count".equals(key)) {
good.setCount(Integer.parseInt(reader.readString()));
} else {
reader.readObject();//读取对象
}
}
reader.endObject();//结束解析对象
}
reader.endArray();//结束解析数组
reader.close();关闭流
reader = null;
The text was updated successfully, but these errors were encountered: