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


    1 JSON结果集

      1 [
      2     {
      3         "J_LP_OPERATE_MAIN": {
      4             "ID": "1900036295",
      5             "FILL_MAN": "周兴福",
      6             "FILL_DEPT": "运维一班",
      7             "STATE": "0",
      8             "WF_INST": "",
      9             "FILL_DATE": "2013-03-18 19:24:10",
     10             "WF_STEP_NAME": "",
     11             "FILL_DEPT_ID": "100000828",
     12             "WF_NAME": "",
     13             "BILL_NO": "",
     14             "OPERATETASK": "许园Ⅰ线305开关由运行转为线路检修",
     15             "BEGINTIME": "",
     16             "ENDTIME": "",
     17             "SENDORDERMAN": "",
     18             "OPERATEMAN": "",
     19             "WATCHMAN": "",
     20             "XKMAN": "",
     21             "NOTE": "",
     22             "DELFLAG": "0",
     23             "OLD_BILL_NO": "",
     24             "ZFFLAG": "0",
     25             "SLR": "",
     26             "ZS": "1",
     27             "FLTIME": "",
     28             "FLTIME_M": "",
     29             "BEGINTIME_M": "",
     30             "ENDTIME_M": "",
     31             "FLTIME_D": "",
     32             "BEGINTIME_D": "",
     33             "ENDTIME_D": "",
     34             "FLTIME_H": "",
     35             "BEGINTIME_H": "",
     36             "ENDTIME_H": "",
     37             "FLTIME_N": "",
     38             "BEGINTIME_N": "",
     39             "ENDTIME_N": "",
     40             "DEPT": "220kV许寺变电站",
     41             "DEPT_ID": "",
     42             "UPBILL_NO": "",
     43             "STATION": "",
     44             "NEXTBILL_NO": "",
     45             "FZR_MAN": "",
     46             "OPER_CS": "",
     47             "PIC_ID": "100008329",
     48             "PIC_LOAD": "0",
     49             "DEV_ID": "100000011",
     50             "ATYPE": "变电",
     51             "OPER_MAN_TYPE": "1",
     52             "DXP": "0",
     53             "WF_STATE": "0",
     54             "WF_CZP_ID": "",
     55             "SHR": "",
     56             "SXLX": "",
     57             "XLRS": "",
     58             "CZPKH": "0",
     59             "ISDXP": "0",
     60             "DEVID": "",
     61             "DEV_NAME": "",
     62             "JXSQ_IDS": "",
     63             "MID": "",
     64             "YGSJ": "",
     65             "YGR": "",
     66             "JHSJ": "",
     67             "FILENAMES": "",
     68             "CZYGID": "",
     69             "YG_DT": "",
     70             "YG_DW": "",
     71             "YG_JSR": "",
     72             "YG_YGR": "",
     73             "DDCZLID": "",
     74             "DDS_TXR": "",
     75             "DEL_STATE": "0",
     76             "DDS_SHR": "",
     77             "DEL_WF_STEP_NAME": "",
     78             "DDS_PZR": "",
     79             "HD1": "",
     80             "XZTB_DT": "",
     81             "JHQR_MAN": "",
     82             "ZYSX": "",
     83             "QD_DAY": "",
     84             "QD_LX": "",
     85             "QD_LB": "",
     86             "QD_CZP_JS": "",
     87             "QD_CZP_JW": "",
     88             "QD_CZP_SCLX": "",
     89             "QD_GDR": "",
     90             "QD_GDSJ": "",
     91             "QD_ZFR": "",
     92             "QD_ZFSJ": "",
     93             "QD_YYGZ_CZPID": "",
     94             "GDJDM": "JNGDJ"
     95         }
     96     },
     97     [
     98         {
     99             "J_LP_OPERATE_SUB": {
    100                 "ID": "1900593076",
    101                 "MID": "1900036295",
    102                 "ORD": "1",
    103                 "DETAIL": "模拟操作",
    104                 "CHECKRESULT": ""
    105             }
    106         },
    107         {
    108             "J_LP_OPERATE_SUB": {
    109                 "ID": "1900593100",
    110                 "MID": "1900036295",
    111                 "ORD": "2",
    112                 "DETAIL": "选择许园Ⅰ线305开关分闸",
    113                 "CHECKRESULT": ""
    114             }
    115         },
    116         {
    117             "J_LP_OPERATE_SUB": {
    118                 "ID": "1900593101",
    119                 "MID": "1900036295",
    120                 "ORD": "3",
    121                 "DETAIL": "检查许园Ⅰ线305开关分闸选线正确",
    122                 "CHECKRESULT": ""
    123             }
    124         },
    125         {
    126             "J_LP_OPERATE_SUB": {
    127                 "ID": "1900593102",
    128                 "MID": "1900036295",
    129                 "ORD": "4",
    130                 "DETAIL": "拉开许园Ⅰ线305开关",
    131                 "CHECKRESULT": ""
    132             }
    133         },
    134         {
    135             "J_LP_OPERATE_SUB": {
    136                 "ID": "1900593103",
    137                 "MID": "1900036295",
    138                 "ORD": "5",
    139                 "DETAIL": "检查表计指示正确,电流A相    A,B相    A,C相    A.",
    140                 "CHECKRESULT": ""
    141             }
    142         },
    143         {
    144             "J_LP_OPERATE_SUB": {
    145                 "ID": "1900593104",
    146                 "MID": "1900036295",
    147                 "ORD": "6",
    148                 "DETAIL": "检查许园Ⅰ线305开关当地后台信号指示正确",
    149                 "CHECKRESULT": ""
    150             }
    151         },
    152         {
    153             "J_LP_OPERATE_SUB": {
    154                 "ID": "1900593105",
    155                 "MID": "1900036295",
    156                 "ORD": "7",
    157                 "DETAIL": "检查许园Ⅰ线305开关保护装置开关位置指示正确",
    158                 "CHECKRESULT": ""
    159             }
    160         },
    161         {
    162             "J_LP_OPERATE_SUB": {
    163                 "ID": "1900593106",
    164                 "MID": "1900036295",
    165                 "ORD": "8",
    166                 "DETAIL": "检查许园Ⅰ线305开关位置指示器确在分位",
    167                 "CHECKRESULT": ""
    168             }
    169         }
    170     ]
    171 ]
    View Code

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

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


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

    3 核心语句

    1         JSONArray jSONArray = new JSONArray(json);
    2         
    3         JSONObject mainBDDZCZPJSONObject= jSONArray.getJSONObject(0);
    4         JSONArray subBDDZCZPJSONArray = jSONArray.getJSONArray(1);
  • 相关阅读:
    iptables阐述防火墙
    升级openssh基于openssl
    Linux密钥认证错误解决
    keychain实现ssh对秘钥免登陆免输入密码
    rpcbind服务死活启动不了
    samba温故知新
    Linux下umask的缺省默认权限
    tomcat在线部署且查看堆栈状态
    mariadb多实例搭建
    rarlinux基于linux-x64
  • 原文地址:https://www.cnblogs.com/YangBinChina/p/3716758.html
Copyright © 2020-2023  润新知