Json数据处理

1.字符串转换为Json数组:取json对象属性值。

String st="[{"tradeDate":"2016-09-27","tradeTime":"09:17","tradeProject":"滴滴快车-黄加农师傅","tradeOtherSide":"北京通达无限科技有限公司","tradeOtherSideName":"","tradeOtherSideAccount":"","tradeAmount":52.30,"tradeStatus":501},{"tradeDate":"2016-10-13","tradeTime":"09:17","tradeProject":"滴滴快车-黄加农师傅","tradeOtherSide":"北京通达无限科技有限公司","tradeOtherSideName":"","tradeOtherSideAccount":"","tradeAmount":32.30,"tradeStatus":501},{"tradeDate":"2016-10-13","tradeTime":"09:50","tradeProject":"滴滴快车-费则龙师傅","tradeOtherSide":"北京通达无限科技有限公司","tradeOtherSideName":"","tradeOtherSideAccount":"","tradeAmount":33.80,"tradeStatus":4},{"tradeDate":"2016-10-14","tradeTime":"09:59","tradeProject":"滴滴快车-沈方良师傅","tradeOtherSide":"北京通达无限科技有限公司","tradeOtherSideName":"","tradeOtherSideAccount":"","tradeAmount":37.60,"tradeStatus":7},{"tradeDate":"2016-10-15","tradeTime":"17:28","tradeProject":"滴滴快车-杨正松师傅","tradeOtherSide":"北京通达无限科技有限公司","tradeOtherSideName":"","tradeOtherSideAccount":"","tradeAmount":25.10,"tradeStatus":8},{"tradeDate":"2016-10-16","tradeTime":"15:42","tradeProject":"滴滴快车-朱龙文师傅","tradeOtherSide":"北京通达无限科技有限公司","tradeOtherSideName":"","tradeOtherSideAccount":"","tradeAmount":47.20,"tradeStatus":601},{"tradeDate":"2016-10-18","tradeTime":"10:07","tradeProject":"滴滴快车-张霞锋师傅","tradeOtherSide":"北京通达无限科技有限公司","tradeOtherSideName":"","tradeOtherSideAccount":"","tradeAmount":35.70,"tradeStatus":601},{"tradeDate":"2016-10-21","tradeTime":"09:59","tradeProject":"滴滴快车-杨美楼师傅","tradeOtherSide":"北京通达无限科技有限公司","tradeOtherSideName":"","tradeOtherSideAccount":"","tradeAmount":37.90,"tradeStatus":601}]"

JSONArray jsArray = JSON.parseArray(st);

JSONObject jsonObject =jsArray.getJSONObject(i);

String date = jsonObject.getString("tradeDate");

String time = jsonObject.getString("tradeTime");

posted @ 2016-12-31 16:37  小学生II  阅读(468)  评论(0编辑  收藏  举报