JSON raw Data
{"Total": 1, "Rows": [{"ID": 1, "Title": "The first year of Taizhou Junior middle School recruits the first grade sports specialty notice", "Content": "",
"Type": "Receiveusername", "Cai", "Isread": 0, "senddate": "2014-07-18 15:21:40", "Sendusername": "Web Developer"}]}
Custom Model Store parsed results
Public classMessagecenter {Private intID; PrivateString Title; PrivateString Content; PrivateString Type; PrivateString Receiveusername; Private intIsread; PrivateString senddate; PrivateString Sendusername; Public intGetID () {returnID; } Public voidSetID (intID) {ID=ID; } PublicString GetTitle () {returnTitle; } Public voidSettitle (String title) {Title=title; } PublicString getcontent () {returnContent; } Public voidsetcontent (String content) {content=content; } PublicString GetType () {returnType; } Public voidsetType (String type) {type=type; } PublicString Getreceiveusername () {returnReceiveusername; } Public voidsetreceiveusername (String receiveusername) {receiveusername=Receiveusername; } Public intGetisread () {returnIsread; } Public voidSetisread (intisread) {Isread=Isread; } PublicString getsenddate () {returnsenddate; } Public voidsetsenddate (String senddate) {senddate=senddate; } PublicString Getsendusername () {returnSendusername; } Public voidsetsendusername (String sendusername) {sendusername=Sendusername; }}
Importjava.util.List; Public classMessagecenterjsonbean {Private intTotal ; PrivateList<messagecenter>rows; Public intgettotal () {returnTotal ; } Public voidSettotal (intTotal ) { This. Total =Total ; } PublicList<messagecenter>getRows () {returnrows; } Public voidSetrows (list<messagecenter>rows) { This. rows =rows; }}
Parsing json,resultstring as JSON raw data
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) {}}