-2

The response is something like this

Array({"ResultSet":{"Query":"xxxx","Result":[]}})

How to parse the string into a NSArray?

0

1 Answer 1

2

it should work with NSJSONSerialization, it converts NSData input to all foundation objects (NSArray, NSDictionary):

NSError *error;
NSArray *data = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if (error) {
    //handle error
} else {
    NSLog(@"%@", data);
}
Sign up to request clarification or add additional context in comments.

2 Comments

It seems it doesn't work with array data. I got the following error[ error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x10f73c2b0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}]
your response might be malformed. did you verify it with a json validation service (e.g. jsonlint.com)?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.