首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Json语法异常: java .io .EOF异常

Json语法异常: java .io .EOF异常
EN

Stack Overflow用户
提问于 2018-03-09 06:41:15
回答 1查看 1.1K关注 0票数 0

我能知道为什么会发生这样的错误吗?

COM。谷歌。葛森。JsonSyntaxException: javaio.EOFException:第3782行第1列的输入结束

代码语言:javascript
复制
private void initView() {

    String js = loadJSONFromAsset(getActivity(), "brandtypes.json");
    Gson g = new Gson();
    BrandccokersHub p = g.fromJson(js, Brandcookers.class);
    List<BrandCountryList> ctry = p.getCountryList();
    List<BrandTypeBrandList> ctrycook = new ArrayList<>();
    for (int i = 0; i < ctry.size(); i++) {
        ctrycook.clear();
        if (ctry.get(i).getBrandId() == mPosition) {
            ctry.get(i).getBrandType();
            ctryCook.addAll(ctry.get(i).getBrandList());

            break;
        }
    }
}
EN

回答 1

Stack Overflow用户

发布于 2018-03-09 07:42:42

试试这段代码

代码语言:javascript
复制
 private void initView() {

    String js = loadJSONFromAsset(getActivity(), "brandtypes.json");
    Gson g = new Gson();
    Brandcookers p = g.fromJson(js, Brandcookers.class);
    List<BrandCountryList> ctry = p.getCountryList();
    List<BrandTypeBrandList> ctrycook = new ArrayList<>();
    for (int i = 0; i < ctry.size(); i++) {
        ctrycook.clear();
        if (ctry.get(i).getBrandId() == mPosition) {
            ctry.get(i).getBrandType();
            ctryCook.addAll(ctry.get(i).getBrandList());

            break;
        }
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49187963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档