Skip to content
New issue

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

[FEATURE] 能否给一个大批量读取 100mb json格式的demo #3321

Open
fakerlove1 opened this issue Jan 26, 2025 · 0 comments
Open

[FEATURE] 能否给一个大批量读取 100mb json格式的demo #3321

fakerlove1 opened this issue Jan 26, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@fakerlove1
Copy link

一直报错
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;

@fakerlove1 fakerlove1 added the enhancement New feature or request label Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant