进口com.alibaba.fastjson.JSON; 进口com.alibaba.fastjson.JSONArray; 进口com.alibaba.fastjson.JSONObject; 进口io.swagger.models.auth.In; 进口java.io.IOException; 进口java.security.KeyManagementException; 进口java.security.NoSuchAlgorithmException; 进口java.util.Iterator;/* * *由Administratorsuccess \”:真的,\“数据\”:[{\“building_id \”, \“* * * \”, \“building_num \”, \“* * \”, \“room_name \”, \“* * \”, \“door_name \”, \“* * \”, \“电气\”:\“* * \”}]}]”; 字符串b=s.substring (0, s.length () 1); 字符串c=b。substring (b.length ()); System.out.println (b +“b___”); JSONObject jsonx=JSON.parseObject (c); JSONArray ja=jsonx.getJSONArray(“数据”); for (int i=0;我& lt;ja.size ();我+ +){ JSONObject乔=ja.getJSONObject(我); 字符串building_id=jo.getString (“building_id”); System.out.println (building_id +“building_id>在祝辞祝辞祝辞”); }//第二种格式/* * * ( { “密码”:“* 1234567890”, “成功”:“真正的” } ] */字符串s="[{\“成功\”,\“\”,\“密码\”,\“* 1234567890 \”}]”; 字符串b=s.substring (0, s.length () 1); 字符串c=b。substring (b.length ()); System.out.println (c +“c___”); JSONObject reagobj=JSONObject.fromObject (c); 字符串名称=reagobj.getString(“密码”); System.out.println(名字+名字,,,,,,); 字符串密码=jm.getString(“密码”); System.out.println(密码); System.out.println(“看看有没有值”+密码);//第三种格式/* * * { "数据":{ :“access_token 5 a7040ccf66bafd06acd39b6f61c19230eaba426755509646d6da23ddd9fb206”, “expires_second”: 36000 }, :“rlt_code HH0000”, :“rlt_msg成功” } */字符串res="{\“数据\”:{\“access_token \”, \“5 a7040ccf66bafd06acd39b6f61c19230eaba426755509646d6da23ddd9fb206 \”, \“expires_second \”: 36000}, \“rlt_code \”, \“HH0000 \”, \“rlt_msg \”, \“成功\“}”; JSONObject JSONObject=JSON.parseObject (res); 字符串数据=https://www.yisu.com/zixun/jsonObject.getString(“数据”); JSONObject jsondata=https://www.yisu.com/zixun/JSON.parseObject(数据); 字符串标记=jsondata.getString (“access_token”);//第四种格式/* * * { “数据”: { “总”:23日, “开始”:0, “total_page”: 3, “行”: ( {“op_way”:“3”,“user_mobile”:“15321918571”,“op_time”: 1493881391976,“pwd_no”: 30}, {“op_way”:“1”,“op_time”: 1493880995000,“pwd_no”: 31} ), “current_page”: 1、 “页大小”:10 }, :“rlt_code HH0000”, :“rlt_msg成功” } */字符串res="{\“数据\”:{\ \“\”:23日,“开始\”:0,\“total_page \”: 3 \ \“行”:[{\“op_way \”, \“1 \”, \“op_time \”: 1493884964000, \“pwd_no \”: 31}, {\“op_way \”, \“3 \”, \“user_mobile \”, \“18518517491 \”, \“op_time \”: 1493884615032, \“pwd_no \”: 30}, {\“op_way \”, \“3 \”, \“user_mobile \”, \“18518517491 \”, \“op_time \”: 1493883836552, \“pwd_no \”: 30}, {\“op_way \”, \“1 \”, \“op_time \”: 1493883294000, \“pwd_no \”: 31}, {\“op_way \”, \“1 \”, \“op_time \”: 1493883256000, \“pwd_no \”: 31}, {\“op_way \”, \“3 \”, \“user_mobile \”, \“15321918571 \”, \“op_time \”: 1493883015371, \“pwd_no \”: 30}, {\“op_way \”, \“1 \”, \“op_time \”: 1493882007000, \“pwd_no \”: 31}, {\“op_way \”, \“3 \”, \“user_mobile \”, \“15321918571 \”, \“op_time \”: 1493881498520, \“pwd_no \”: 30}, {\“op_way \”, \“3 \”, \“user_mobile \”, \“15321918571 \”, \“op_time \”: 1493881391976, \“pwd_no \”: 30}, {\“op_way \”, \“1 \”, \“op_time \”: 1493880995000, \“pwd_no \”: 31}], \“current_page \”: 1, \“页大小\”:10},\“rlt_code \”, \“HH0000 \”, \“rlt_msg \”, \“成功\“}”; JSONObject JSONObject=JSON.parseObject (res); 字符串数据=https://www.yisu.com/zixun/jsonObject.getString(“数据”); JSONObject JSONObject=JSON.parseObject(数据); JSONArray ja=jsonObjects.getJSONArray(“行”); for (int i=0;我& lt;ja.size ();我+ +){ JSONObject乔=ja.getJSONObject(我); 字符串op_way=jo.getString (“op_way”); 字符串op_time=jo.getString (“op_time”); SimpleDateFormat SimpleDateFormat=new SimpleDateFormat (“yyyy-MM-dd HH: mm: ss”); 长lt=new (op_time); 日期日期=new日期(lt); res=simpleDateFormat.format(日期); 字符串pwd_no=jo.getString (“pwd_no”); 字符串user_mobile=jo.getString (“user_mobile”); System.out.println (op_way + res + pwd_no + user_mobile +“- - - - - - - - - - - -”); } } }java的JsonObject对象提取值方法