To McDonald's, KFC coupons interface data for an example of data analysis method, simple and understandable, this is my personal feel is a relatively simple and understandable JSON data parsing method:
Look at the code for one of the classes
Package Com.example.text_json_deno_model;import Java.util.arraylist;import Java.util.list;import Org.json.jsonarray;import Org.json.jsonexception;import Org.json.jsonobject;public class Coupons {private List< kfc> coupons;p rivate string end;private int id;private string label;private string start;public list<kfc> GetC Oupons () {return coupons;} public void setcoupons (list<kfc> coupons) {this.coupons = coupons;} Public String Getend () {return end;} public void SetEnd (String end) {this.end = end;} public int getId () {return ID;} public void setId (int id) {this.id = ID;} Public String Getlabel () {return label;} public void SetLabel (String label) {this.label = label;} Public String Getstart () {return start;} public void Setstart (String start) {This.start = start;} Public coupons (Jsonobject jsonobject) throws Jsonexception{constructjson (Jsonobject);} private void Constructjson (Jsonobject jsonobject) throws Jsonexception {if (!jsonobject.isnull ("End")) {End =jsonobject . getString ("End"); if (!jsonobject.isnull ("id")) {ID =jsonobject.getint ("id");} if (!jsonobject.isnull ("label")) {label =jsonobject.getstring ("label");} if (!jsonobject.isnull ("start")) {start =jsonobject.getstring ("Start");} if (!jsonobject.isnull ("coupons")) {list<kfc> KFCs =new arraylist<kfc> (); Jsonarray object =jsonobject.getjsonarray ("Coupons"), if (object instanceof Jsonarray) {for (int i = 0; i < Object.le Ngth (); i++) {KFC KFC =new KFC (Object.getjsonobject (i)); Kfcs.add (KFC);} Coupons =kfcs;}}}
It is easy to parse the data yourself into an object. I sent a demo I wrote up,: http://download.csdn.net/detail/u012808234/8385311
To McDonald's, KFC coupon interface data as an example of data analysis method, easy to understand