0

我有以下 JSON

{

    "data": {
        "status": 200,
        "message": "OK",
        "text": "Succesvol ingelogd.",
        "user": {
            "cu_id": 1,
            "cu_status_id": 0,
            "cu_company_id": 1,
            "cu_function_id": 1,
            "cu_department_id": 1,
            "cu_email": "info@sanmax.be",
            "cu_first_name": "First",
            "cu_last_name": "Last",
            "cu_phone_intern": "",
            "cu_mobile_phone": "",
            "cu_street": "",
            "cu_number": "",
            "cu_bus": "",
            "cu_postalcode": "",
            "cu_location": "",
            "cu_country": "",
            "cu_birthdate": "0000-00-00",
            "cu_picture": "",
            "cu_comment": "",
            "cu_ison_reminder_email": 0,
            "cu_ison_reminder_app": 0,
            "cu_ison_reminder_web": 0,
            "cu_first_use": 1
        },
        "company": {
            "c_id": 1,
            "c_name": "Sanmax",
            "c_phone": "089 68 06 39",
            "c_fax": "089 856 929",
            "c_website": "www.sanmax.be"
        },
        "function": {
            "cf_id": 1,
            "cf_name": "Developer"
        },
        "department": {
            "cd_id": 1,
            "cd_name": "Development"
        },
        "statuses": [
            {
                "cs_id": 3,
                "cs_company_id": 1,
                "cs_name": "Bezet",
                "cs_default": 1,
                "cs_image": ""
            },
            {
                "cs_id": 1,
                "cs_company_id": 1,
                "cs_name": "Online",
                "cs_default": 0,
                "cs_image": ""
            },
            {
                "cs_id": 2,
                "cs_company_id": 1,
                "cs_name": "Offline",
                "cs_default": 0,
                "cs_image": ""
            },
            {
                "cs_id": 4,
                "cs_company_id": 1,
                "cs_name": "Afwezig",
                "cs_default": 0,
                "cs_image": ""
            }
        ]
    }

}

如果我只有一个对象,我知道我应该如何映射。这里我有一个数据对象。如果一切正常,我在数据对象中得到一个 data.status 200,但我也得到一个 userObject、一个 companyObject、一个 functionObject、一个 departmentObject 和一个 statusObject(其中还包含其他对象)。

但如果我没有得到 200 data.status 代码,假设我得到了 404 data.status 代码。我只得到一个状态码和一条消息。

我应该如何在restkit中映射它?

任何帮助,亲切的问候

4

1 回答 1

0

如果出现错误,服务器不应以状态 200 响应。因此,据我所知,这永远不会映射到 RestKit 0.20 中的错误。

于 2013-01-08T18:05:27.803 回答