每日学习

今天继续学习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'
作者:哦心有
本文版权归作者和博客园共有,欢迎转载,但必须给出原文链接,并保留此段声明,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/haobox/p/14908840.html