每日学习

今天继续学习okhttp

 JSONArray jsonArray=new JSONArray(result);
        list=new ArrayList<>();
        listfre=new ArrayList<>();
        page=1;
        page2=1;
        for(int i=0;i<jsonArray.length();i++)
        {
            JSONObject jsonObject=jsonArray.getJSONObject(i);
            String title=jsonObject.getString("title");
            String time=jsonObject.getString("time");
            String place=jsonObject.getString("place");
            String content=jsonObject.getString("content");
            String img=jsonObject.getString("img");
            Bean bean=new Bean();
            bean.setTitle(title);
            bean.setTime(time);
            bean.setPlace(place);
            bean.setContent(content);
            bean.setImg(img);
            list.add(bean);
        }

 对获取的后端数据(服务器)进行处理

需要导包

implementation 'com.google.code.gson:gson:2.8.5'

 

posted @ 2021-05-07 22:07  哦心有  阅读(16)  评论(0编辑  收藏  举报