4

How should I use RestKit to fetch a JSON array of strings like this :

["Paris", "London", "Brussels", "New York"]

I tried to make an object mapping but since there's no key path or attribute, I don't know what to map.

I don't even need a mapping, the result could just be an array or a dictionary. Is there a way to achieve that?

EDIT:

For more info & solution : https://github.com/RestKit/RestKit/issues/1290

Alexis
  • 16,629
  • 17
  • 62
  • 107

1 Answers1

4

You need to create a mapping with a nil keypath. This instructs RestKit to directly map the string values into your destination objects. See this reference.

Wain
  • 118,658
  • 15
  • 128
  • 151
  • Wain I m wonder what If I need to do opposite, I mean if I need to send flat array of strings in post service with body like ["123", "123", "123"] ? – Aqib Mumtaz Oct 24 '16 at 13:35
  • then you shouldn't use RestKit, just use the underlying AFNetworking @AqibMumtaz – Wain Oct 24 '16 at 13:53
  • I m using a lot restkit in my app, I need to mange request some how, I just came across to your own comment, just looking into it http://stackoverflow.com/questions/28369558/posting-json-array-of-strings-with-restkit#comment45311998_28369558 – Aqib Mumtaz Oct 24 '16 at 14:00