一. 要解析的Json字符串,没有格式化前的..

{success:true,result:{"tpn":{"content":{"resource_def":[{"id":1,"passwd":123,"user_name":"chm","isdisc_drive":1,"server_ip":"132.132.100.254","program_name":"name%PSfomZrmi5/moYzpnaInOw==;server_ip%PScxMzIuMTMyLjEwMC4yNTQnOw==;server_port%PTMzODk7;user_name%PSdjaG0nOw==;passwd%PScxMjMnOw==;program_name%PSdhZHRcXGNobVxceHVuaSc7;move_path%PSdodHRwczovLzEzMi4xMzIuMjU0Ojg4ODgvdG5wMmcnOw==;isprint%PXRydWU7;isdisc_drive%PXRydWU7","name":"虚拟桌面","move_path":"aHR0cHM6Ly8xMzIuMTMyLjI1NDo4ODg4L3RucDJn","type":3,"isprint":1,"server_port":3389},{"id":2,"passwd":"qqq","user_name":"qqq","isdisc_drive":0,"server_ip":"100.200.122.2","program_name":"name%PSdxcSc7;server_ip%PScxMDAuMjAwLjEyMi4yJzs=;server_port%PTMzODk7;user_name%PSdxcXEnOw==;passwd%PSdxcXEnOw==;program_name%PSdub3RlcGFkLmV4ZSc7;move_path%PSdEOic7;isprint%PWZhbHNlOw==;isdisc_drive%PWZhbHNlOw==","name":"qq","move_path":"RDo=","type":3,"isprint":0,"server_port":3389}]},"result":0,"tunnel_type":0}}}

二.这个是原始没有格式化的,格式化后的

{
    "success": true,
    "result": {
        "tpn": {
            "content": {
                "resource_def": [
                    {
                        "id": 1,
                        "passwd": 123,
                        "user_name": "chm",
                        "isdisc_drive": 1,
                        "server_ip": "132.132.100.254",
                        "program_name": "name%PSfomZrmi5/moYzpnaInOw==;server_ip%PScxMzIuMTMyLjEwMC4yNTQnOw==;server_port%PTMzODk7;user_name%PSdjaG0nOw==;passwd%PScxMjMnOw==;program_name%PSdhZHRcXGNobVxceHVuaSc7;move_path%PSdodHRwczovLzEzMi4xMzIuMjU0Ojg4ODgvdG5wMmcnOw==;isprint%PXRydWU7;isdisc_drive%PXRydWU7",
                        "name": "虚拟桌面",
                        "move_path": "aHR0cHM6Ly8xMzIuMTMyLjI1NDo4ODg4L3RucDJn",
                        "type": 3,
                        "isprint": 1,
                        "server_port": 3389
                    },
                    {
                        "id": 2,
                        "passwd": "qqq",
                        "user_name": "qqq",
                        "isdisc_drive": 0,
                        "server_ip": "100.200.122.2",
                        "program_name": "name%PSdxcSc7;server_ip%PScxMDAuMjAwLjEyMi4yJzs=;server_port%PTMzODk7;user_name%PSdxcXEnOw==;passwd%PSdxcXEnOw==;program_name%PSdub3RlcGFkLmV4ZSc7;move_path%PSdEOic7;isprint%PWZhbHNlOw==;isdisc_drive%PWZhbHNlOw==",
                        "name": "qq",
                        "move_path": "RDo=",
                        "type": 3,
                        "isprint": 0,
                        "server_port": 3389
                    }
                ]
            },
            "result": 0,
            "tunnel_type": 0
        }
    }
}

三. 通过json Viewer查看的Json

jsonviewer

四.Android解析的步骤

appresult=”以上的JsonString”;

        JSONObject appJsonResult = JsonUtil.getJSONObject(appresult);

        String isAppSuccess = appJsonResult.getString("success");
        if (isAppSuccess.equals("true")) {

            // JSONObject _result= appJsonResult.getJSONObject("result") ;

            JSONObject content = appJsonResult.getJSONObject("result")
                    .getJSONObject("tpn").getJSONObject("content");

            JSONArray resource_def = content.getJSONArray("resource_def");

            for (int i = 0; i < resource_def.length(); i++) {
                DesktopInfo desktop_resource = new DesktopInfo();
                JSONObject desktop = resource_def.getJSONObject(i);
                desktop_resource.setId(desktop.getString("id"));
                desktop_resource.setPasswd(desktop.getString("passwd"));
                desktop_resource.setUser_name(desktop.getString("user_name"));
                desktop_resource.setIsdisc_drive(desktop
                        .getString("isdisc_drive"));
                desktop_resource.setServer_ip(desktop.getString("server_ip"));
                desktop_resource.setProgram_name(desktop
                        .getString("program_name"));
                desktop_resource.setName(desktop.getString("name"));
                desktop_resource.setMove_path(desktop.getString("move_path"));
                desktop_resource.setType(desktop.getString("type"));
                desktop_resource.setIsprint(desktop.getString("isprint"));
                desktop_resource.setServer_port(desktop
                        .getString("server_port"));
                desktopList.add(desktop_resource);
                // resource_def[i]
                // resource_def[i].getString("success")
                // desktop_resource.setId(resource_def[i].);
            }

            Log.i(TAG, "list大小=" + desktopList.size());

        }