0

I'm a beginner to RestKit and I'm finding difficult to get the hang of it, beats using standard cocoa to do webservice response parsing, but still feels lightyears behind .net or java...

Anyhow, to the point. I have a WCF webservice which returns something like this:

{"GetSiteMapResult":"iVBORw0KGgoAAAANSUhEUgAAB\/cAAAf3CAIAAACicn4JAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAP+lSURBVHhe7P0JoF1HcSeMS2\/X0y5ZepK8St5ly7HxgsxiB2TH"}

GetSiteMapResult followed by a large string.

How can I parse this into an NSString using ReskKit? I tried adding a mapping, but I'm not sure what the code would be for this, for instance all examples are along the lines of:

RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[myClass class]];
[mapping mapKeyForPath:@"node" toAttribute:@"attributeInMyClass"];
[[RKObjectManager sharedManager].mappingProvider setMapping:mapping forKeyPath:@"RootNodeInReturnJSON"];

But since this is an object I'm returning in the service response, only a string, I'm not sure how to do this.

SoManyGoblins
  • 5,605
  • 8
  • 45
  • 65
  • 1
    You do not need RestKit to parse such a simple response, moreover i guess RestKit can not parse into NSString. RestKit is a real life saver when you have more complicated JSON responses. In order to parse this response i would create a class with one string ivar & map the response accordingly. – mja Oct 06 '11 at 22:58
  • I see, what would you recommend to parse simple JSON? – SoManyGoblins Oct 07 '11 at 12:19
  • 1
    i'd go with JSONKit, https://github.com/johnezang/JSONKit – mja Oct 07 '11 at 12:25
  • Thanks, if you could post your comment as answer, I could mark it as such :) – SoManyGoblins Oct 07 '11 at 13:01

1 Answers1

1

You do not need RestKit to parse such a simple response, moreover i guess RestKit can not parse into NSString. RestKit is a real life saver when you have more complicated JSON responses. In order to parse this response i would create a class with one string ivar & map the response accordingly.

However, i'd recommend using JSONKit to parse simple responses from your webservice api. You may also take a look at the famous ASIHTTP library which will help you for sure with the handling of HTTP communication.

mja
  • 5,056
  • 1
  • 29
  • 40