JSON原数据

{"total":1,"rows":[{"ID":1,"Title":"台州初级中学招收初一年级体育特长生的通告","Content":"",
"Type":"01","ReceiveUserName":"蔡婧怡","IsRead":0,"SendDate":"2014-07-18 15:21:40","SendUserName":"网站开发员"}]}

自定义model存放解析后的结果

public class MessageCenter {
private int ID;
private String Title;
private String Content;
private String Type;
private String ReceiveUserName;
private int IsRead;
private String SendDate;
private String SendUserName; public int getID() {
return ID;
}
public void setID(int iD) {
ID = iD;
}
public String getTitle() {
return Title;
}
public void setTitle(String title) {
Title = title;
}
public String getContent() {
return Content;
}
public void setContent(String content) {
Content = content;
}
public String getType() {
return Type;
}
public void setType(String type) {
Type = type;
}
public String getReceiveUserName() {
return ReceiveUserName;
}
public void setReceiveUserName(String receiveUserName) {
ReceiveUserName = receiveUserName;
} public int getIsRead() {
return IsRead;
}
public void setIsRead(int isRead) {
IsRead = isRead;
}
public String getSendDate() {
return SendDate;
}
public void setSendDate(String sendDate) {
SendDate = sendDate;
}
public String getSendUserName() {
return SendUserName;
}
public void setSendUserName(String sendUserName) {
SendUserName = sendUserName;
}
}
import java.util.List;

public class MessageCenterJsonBean {
private int total;
private List<MessageCenter> rows;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public List<MessageCenter> getRows() {
return rows;
}
public void setRows(List<MessageCenter> rows) {
this.rows = rows;
}
}

解析JSON,resultString为JSON原数据

public static void main(String[] args) {
Gson gson = new Gson();
try {
MessageCenterJsonBean mcj= new GsonBuilder().create().fromJson(resultString, MessageCenterJsonBean.class);
System.out.println(mcj.getTotal());
} catch (Exception e) {
}
}

Android Gson解析复杂Json的更多相关文章

  1. Gson解析复杂Json数据

    背景                                                                   json是一种数据格式,便于数据传输.存储.交换. gson是 ...

  2. java android使用Gson解析泛型json数据

    那就直接开始吧. 在我们获取服务器返回的json数据有时候会出现这种情况,比如: {"body":{"attrName":"feed",&q ...

  3. Android Gson解析json详解

    目前解析json有三种工具:org.json(Java常用的解析),fastjson(阿里巴巴工程师开发的),Gson(Google官网出的),解析速度最快的是Gson,下载地址:https://co ...

  4. Android Gson解析json工具类封装

    package com.springSecurity.gson; import java.util.ArrayList; import java.util.List; import java.util ...

  5. Gson解析复杂JSON字符串的两种方式

    JSON解析可以使用的库: JSONObject(源自Android官方). Gson(源自Google). Jackson(第三方开源库). FastJSON(第三方开源库). 本文例子使用Goog ...

  6. Android数据格式解析对象JSON用法

    1.JSON概念: 一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性,从而可以在不同平台间进行数据交换.JSON采用兼容性很高的文本格式,同时也具备类似于C语言体系的行为. JSON可以将 ...

  7. Android Gson解析

    目前解析json有三种工具:org.json(Java常用的解析),fastjson(阿里巴巴工程师开发的),Gson(Google官网出的),解析速度最快的是Gson,下载地址:https://co ...

  8. Android数据格式解析对象JSON用法(转)

    地址:http://www.cnblogs.com/devinzhang/archive/2012/01/09/2317315.html 里面的重点: JSON解析案例     (1)解析Object ...

  9. Gson解析复杂JSON对象

    例如以下格式JSON: 建立对应的Java对象,注意内部类要定义成静态的 public class HResult { public String total; public String recor ...

随机推荐

  1. MIDA Converter Basic patched for RAD Studio 10.1.2 Berlin (VCL转换到FMX)

    Mida is the only way to try to convert your project from VCL to FireMonkey. Version after version, M ...

  2. error: field 'b' has imcomplete type

    在下面的程序中,在编译时会遇到下面的错误: error: field 'b' has incomplete type 域b是一个不完备的类型,即class B的声明不完备 #include <i ...

  3. 使用ContentPresenter,不使用ContentControl

    参考: https://wpf.2000things.com/2017/04/06/1204-using-a-datatrigger-to-change-content-in-a-contentpre ...

  4. table数据跑马灯效果

    1.使用marquee标签实现普通文本字符串跑马灯效果. <marquee behavior="scroll" scrollamount="3" styl ...

  5. Windows上编译OpenEXR

    注意一定要使用1.0.1版本的ilmbase和1.6.1版本的openexr,其它版本的我测试过,OpenImageIO会编译失败. 解压ilmbase 1.0.1到[工作目录]/openexr/il ...

  6. 在红帽RHEL7.0里配置网卡的四种方法

    第一种方法 :采用vim编辑器来配置: 1.  如下图的步骤所示: 2.  输入这个命令后进行配置成下方图片里的内容: 3.  然后退出vim 编辑器,然后重新启动一下网络服务配置: 4.这些配置完后 ...

  7. 模拟实现strstr和strrstr

    strstr函数用于判断str2是否是str1的子串,如果是,则返回str2在str1中首次出现位置的地址,如果不是则返回NULL.其模拟实现代码如下:#include<iostream> ...

  8. [ActionScript 3.0] 简单倒计时

    import flash.utils.Timer; import flash.events.TimerEvent; import flash.text.TextField; var text:Text ...

  9. JavaScript Debug 之 Console

    简评:只知道 console.log ?是时候提升一下对 console 的认知了. JavaScript console 是现代浏览器的一种内置功能,它允许开发者: 查看网页上的错误和警告日志. 使 ...

  10. excel的公式:查找匹配某个值的单元格--MATCH()

    这个非常简单,没啥说的,D1位置是显示这个值所在的行数,如果是跨表,就在匹配区域前面加上  sheetName!