Mapping a JSON response to an object using RestKit and Objective-C

前端 未结 2 891
庸人自扰
庸人自扰 2020-12-30 18:17

I am relatively new to Objective-C and am attempting to use RestKit to receive a JSON response from a web service. I have successfully received the data back to my applicat

2条回答
  •  再見小時候
    2020-12-30 18:53

    You need to pass the returned JSON string into a JSON parser. I use SBJSON. You can then use the resulting dictionary to populate the properties of your object.

    RestKit seems to have native objects that encapsulate four different JSON parsers. However, I'd advise caution because they seem to assume that the top level parsed object will always be a dictionary.

    As another aside, the example in your question is not valid JSON. It should look like this:

    {"id":"1","Translation":"Test"}
    

提交回复
热议问题