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. js 格式化时间

    //格式化时间 function time_format(time) { return new Date(parseInt(time) * 1000).toLocaleString().replace ...

  2. [LeetCode 题解]: Pascal's Triangle

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  3. LEFT JOIN与RIGHT JOIN学习笔记

    SELECT COUNT(*) FROM [tbiz_PuzzleBasic] SELECT A.BasicID,A.Name,A.Gender,B.WorkID,B.Company,B.Positi ...

  4. python 使用跨平台文件锁

    #encoding=utf-8 print '中国' #使用跨平台文件锁 import os if os.name == 'nt': import win32con,win32file,pywinty ...

  5. 【后缀数组之height数组】

    模板奉上 int rank[maxn],height[maxn]; void calheight(int *r,int *sa,int n) { ; ;i<=n;i++) rank[sa[i]] ...

  6. TCP协议中URG和PSH位

    URG(紧急位):设置为1时,首部中的紧急指针有效:为0时,紧急指针没有意义. PSH(推位):当设置为1时,要求把数据尽快的交给应用层,不做处理 通常的数据中都会带有PSH但URG只在紧急数据的时设 ...

  7. [ActionSprit 3.0] FMS服务器带宽检测

    package { import flash.display.Sprite; import flash.net.NetConnection; import flash.events.NetStatus ...

  8. Python报错信息收集(1)

    UnboundLocalError: local variable 'count' referenced before assignment 局部变量错误:赋值之前引用的本地变量'count' ,un ...

  9. js,timeout,promise执行顺序

    总结 macro-task包括:script(整体代码), setTimeout, setInterval, setImmediate, I/O, UI rendering. micro-task包括 ...

  10. WPF捕获全局未处理异常

    在WPF开发过程中我们一般都用try/catch块来捕获异常,但不是每个异常我们都能捕获,程序总会出现一些意想不到情况,抛出一些未捕获的异常,这时就要用到全局异常捕获,即在程序的最外层加上捕获未处理异 ...