对一个 复杂的json结果进行取值的例子

1 JSON结果集

 [
{
"J_LP_OPERATE_MAIN": {
"ID": "1900036295",
"FILL_MAN": "周兴福",
"FILL_DEPT": "运维一班",
"STATE": "0",
"WF_INST": "",
"FILL_DATE": "2013-03-18 19:24:10",
"WF_STEP_NAME": "",
"FILL_DEPT_ID": "100000828",
"WF_NAME": "",
"BILL_NO": "",
"OPERATETASK": "许园Ⅰ线305开关由运行转为线路检修",
"BEGINTIME": "",
"ENDTIME": "",
"SENDORDERMAN": "",
"OPERATEMAN": "",
"WATCHMAN": "",
"XKMAN": "",
"NOTE": "",
"DELFLAG": "0",
"OLD_BILL_NO": "",
"ZFFLAG": "0",
"SLR": "",
"ZS": "1",
"FLTIME": "",
"FLTIME_M": "",
"BEGINTIME_M": "",
"ENDTIME_M": "",
"FLTIME_D": "",
"BEGINTIME_D": "",
"ENDTIME_D": "",
"FLTIME_H": "",
"BEGINTIME_H": "",
"ENDTIME_H": "",
"FLTIME_N": "",
"BEGINTIME_N": "",
"ENDTIME_N": "",
"DEPT": "220kV许寺变电站",
"DEPT_ID": "",
"UPBILL_NO": "",
"STATION": "",
"NEXTBILL_NO": "",
"FZR_MAN": "",
"OPER_CS": "",
"PIC_ID": "100008329",
"PIC_LOAD": "0",
"DEV_ID": "100000011",
"ATYPE": "变电",
"OPER_MAN_TYPE": "1",
"DXP": "0",
"WF_STATE": "0",
"WF_CZP_ID": "",
"SHR": "",
"SXLX": "",
"XLRS": "",
"CZPKH": "0",
"ISDXP": "0",
"DEVID": "",
"DEV_NAME": "",
"JXSQ_IDS": "",
"MID": "",
"YGSJ": "",
"YGR": "",
"JHSJ": "",
"FILENAMES": "",
"CZYGID": "",
"YG_DT": "",
"YG_DW": "",
"YG_JSR": "",
"YG_YGR": "",
"DDCZLID": "",
"DDS_TXR": "",
"DEL_STATE": "0",
"DDS_SHR": "",
"DEL_WF_STEP_NAME": "",
"DDS_PZR": "",
"HD1": "",
"XZTB_DT": "",
"JHQR_MAN": "",
"ZYSX": "",
"QD_DAY": "",
"QD_LX": "",
"QD_LB": "",
"QD_CZP_JS": "",
"QD_CZP_JW": "",
"QD_CZP_SCLX": "",
"QD_GDR": "",
"QD_GDSJ": "",
"QD_ZFR": "",
"QD_ZFSJ": "",
"QD_YYGZ_CZPID": "",
"GDJDM": "JNGDJ"
}
},
[
{
"J_LP_OPERATE_SUB": {
"ID": "1900593076",
"MID": "1900036295",
"ORD": "1",
"DETAIL": "模拟操作",
"CHECKRESULT": ""
}
},
{
"J_LP_OPERATE_SUB": {
"ID": "1900593100",
"MID": "1900036295",
"ORD": "2",
"DETAIL": "选择许园Ⅰ线305开关分闸",
"CHECKRESULT": ""
}
},
{
"J_LP_OPERATE_SUB": {
"ID": "1900593101",
"MID": "1900036295",
"ORD": "3",
"DETAIL": "检查许园Ⅰ线305开关分闸选线正确",
"CHECKRESULT": ""
}
},
{
"J_LP_OPERATE_SUB": {
"ID": "1900593102",
"MID": "1900036295",
"ORD": "4",
"DETAIL": "拉开许园Ⅰ线305开关",
"CHECKRESULT": ""
}
},
{
"J_LP_OPERATE_SUB": {
"ID": "1900593103",
"MID": "1900036295",
"ORD": "5",
"DETAIL": "检查表计指示正确,电流A相 A,B相 A,C相 A.",
"CHECKRESULT": ""
}
},
{
"J_LP_OPERATE_SUB": {
"ID": "1900593104",
"MID": "1900036295",
"ORD": "6",
"DETAIL": "检查许园Ⅰ线305开关当地后台信号指示正确",
"CHECKRESULT": ""
}
},
{
"J_LP_OPERATE_SUB": {
"ID": "1900593105",
"MID": "1900036295",
"ORD": "7",
"DETAIL": "检查许园Ⅰ线305开关保护装置开关位置指示正确",
"CHECKRESULT": ""
}
},
{
"J_LP_OPERATE_SUB": {
"ID": "1900593106",
"MID": "1900036295",
"ORD": "8",
"DETAIL": "检查许园Ⅰ线305开关位置指示器确在分位",
"CHECKRESULT": ""
}
}
]
]

2 获取 JSON结果集文件的语句

         InputStream inputStream = getResources().openRawResource(com.plugin.bddzczp.pluginbddzczp.R.raw.aa);
String result = getString(inputStream);

我把我的JSON结果集放在了工程中的res-->raw 文件夹下,名称是aa.txt

3 核心语句

         JSONArray jSONArray = new JSONArray(json);

         JSONObject mainBDDZCZPJSONObject= jSONArray.getJSONObject(0);
JSONArray subBDDZCZPJSONArray = jSONArray.getJSONArray(1);
上一篇:oracle存储过程中循环游标,变量的引用


下一篇:js eval()执行传参函数的写法