I will not talk about JSON.
Here is only local data, and the interaction between the client and the server is not simulated.
Jsonarray;
Jsonobject;
String JSON = "[{room_id: '123 ',"
+ "Ms_ip: '192. 168.1.227 ',"
+ "Ms_port: '80 ',"
+ "Txt_ip: '192. 168.1.228 ',"
+ "Txt_port: '80 ',"
+ "Room_name: 'passion video ',"
+ "Room_pic: 'http: // room.imichat.com/room/2011/10/09/jqsp.png ',"
+ "Order_status: '1 ',"
+ "Try_status: '1 ',"
+ "Try_time: '5 ',"
+ "Induction:" I regret it for 30 years, but I don't regret it for 80 years ',"
+ "Room_pic_num: '2 ',"
+ "Room_pic_num_url: [{room_pic: 'http: // response,"
+ "Room_order_way: [{bill_name: 'aaa', price: '10', content: '1 hour/meta'}]"
+ "}]";
String encode = codec. encode (JSON, "UTF-8 ");
String decode = codec. Decode (encode, "UTF-8 ");
Try {
Jsonarray = new jsonarray (decode );
System. Out. println (jsonarray. tostring ());
For (INT I = 0; I <jsonarray. Length (); I ++ ){
Jsonobject = (jsonobject) jsonarray. getjsonobject (I );
System. Out. println (jsonobject. getint ("room_id ")
+ "\ N" + jsonobject. getstring ("ms_ip ")
+ "\ N" + jsonobject. getstring ("ms_port ")
+ "\ N" + jsonobject. getstring ("txt_ip ")
+ "\ N" + jsonobject. getstring ("txt_port ")
+ "\ N" + jsonobject. getstring ("room_name ")
+ "\ N" + jsonobject. getstring ("room_pic ")
+ "\ N" + jsonobject. getstring ("order_status ")
+ "\ N" + jsonobject. getstring ("try_status ")
+ "\ N" + jsonobject. getstring ("try_time ")
+ "\ N" + jsonobject. getstring ("induction ")
+ "\ N" + jsonobject. getstring ("room_pic_num ")
);
Jsonarray roompicnumurlarray = new jsonarray (jsonobject. getstring ("room_pic_num_url "));
For (Int J = 0; j <roompicnumurlarray. Length (); j ++ ){
Jsonobject roompicnumurlobject = roompicnumurlarray. getjsonobject (j );
System. Out. println ("\ n \ t" + roompicnumurlobject. getstring ("room_pic") + "\ n ");
}
Jsonarray roomorderwayarray = new jsonarray (jsonobject. getstring ("room_order_way "));
System. Out. println (roomorderwayarray. tostring ());
For (int K = 0; k <roomorderwayarray. Length (); k ++ ){
Jsonobject roomorderwayobject = roomorderwayarray. getjsonobject (k );
System. Out. println ("\ t" + roomorderwayobject. getstring ("bill_name ")
+ "\ T" + roomorderwayobject. getstring ("price ")
+ "\ T" + roomorderwayobject. getstring ("content") + "\ n ");
}
}
} Catch (jsonexception e ){
// Todo auto-generated Catch Block
E. printstacktrace ();
}
String encode = codec. encode (JSON, "UTF-8 ");
String decode = codec. Decode (encode, "UTF-8 ");
Test the correctness of character encryption. The previous article contains code.