如何从网络中获取json数据信息(补)

来源:互联网 发布:怎么查看淘宝会员等级 编辑:程序博客网 时间:2024/05/17 03:04

上一篇中小编写了如何获取json数据信息,可是缺少了关键性的两个文件——我们在获取数据是,要有一个用来定义获取信息属性的文件!

下面小编来补上上一篇中缺少的两个文件:
这里写图片描述

News.java

package com.example.weekone.bean;public class News {    String news_id;    String news_summary;    String news_title;    String pic_url;    public String getNews_id() {        return news_id;    }    public void setNews_id(String news_id) {        this.news_id = news_id;    }    public String getNews_summary() {        return news_summary;    }    public void setNews_summary(String news_summary) {        this.news_summary = news_summary;    }    public String getNews_title() {        return news_title;    }    public void setNews_title(String news_title) {        this.news_title = news_title;    }    public String getPic_url() {        return pic_url;    }    public void setPic_url(String pic_url) {        this.pic_url = pic_url;    }    public News(String news_id, String news_summary, String news_title,            String pic_url) {        super();        this.news_id = news_id;        this.news_summary = news_summary;        this.news_title = news_title;        this.pic_url = pic_url;    }    @Override    public String toString() {        return "News [news_id=" + news_id + ", news_summary=" + news_summary                + ", news_title=" + news_title + ", pic_url=" + pic_url + "]";    }}

NewsData.java

package com.example.weekone.bean;import java.util.ArrayList;import java.util.List;public class NewsData {    String info;    int status;    List<News> data = new ArrayList<News>();    public String getInfo() {        return info;    }    public void setInfo(String info) {        this.info = info;    }    public int getStatus() {        return status;    }    public void setStatus(int status) {        this.status = status;    }    public List<News> getData() {        return data;    }    public void setData(List<News> data) {        this.data = data;    }    @Override    public String toString() {        return "NewsData [info=" + info + ", status=" + status + ", data="                + data + "]";    }}

好了,有了这两个文件,就可以从网络中获取json文件的信息了,上一篇中缺少的文件就只有这两个了,在这里小编给各位读者朋友说声抱歉了,实在不好意思了,不会再有下次了!(^ _ ^)