Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get values from JSON string - Objective C

I have this JSON response string:

{"d":"{\"ID_usuario\":\"000130\",\"Nombre\":null,\"Vipxlo\":0,\"Provmun\":null,\"Descuentos\":null,\"Listaviplocal\":null}"}`

With this code:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
{
    //Check valid signal

    connection = nil;

    NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    //data =nil;

    NSArray *jsonArray = [responseString JSONValue];

How can I do it?

like image 205
roof Avatar asked Mar 10 '26 13:03

roof


1 Answers

When you can afford to require iOS 5 you should try NSJSONSerialization.

Your code could look like this but I suggest reading the Docs first.

    NSArray* jsonArray = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:someError]
like image 95
Maximilian Liesegang Avatar answered Mar 12 '26 02:03

Maximilian Liesegang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!