0
votes

I am using .NET web service in my iOS app. I am getting JSON as response. I am unable to parse that response as it is hard on.Can you please share an idea to do that.Below I have shown the same response for that.

  1. [ {"vehiclemodel":"ASHOK LEYLAND STILE
    LE","cubiccapacity":"1461","typeoffuel":"DIESEL"},
    {"vehiclemodel":"ASHOK LEYLAND STILE
    LS","cubiccapacity":"1461","typeoffuel":"DIESEL"}, ] version="1.0" encoding="utf-8"?> xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
2
That does not look like well formed JSON. - Duncan C

2 Answers

0
votes

I am getting JSON as response.

No, you're not, what you've copied looks like almost-valid JSON followed by a partial xml header.

Once you've fixed this, you'll be able to use e.g. NSJSONSerialization to parse the response.

-1
votes

You try this code for dictionary. I get all key of dictionary after then i run a loop on keys then get all values one by one from dictionary and store in arrValues.

if([responseObject isKindOfClass:[NSArray class]])
            {
                NSArray *arrResponse = responseObject;
                for (int i=0; i<arrResponse.count; i++)
                {
                     id myResponse = [arrResponse objectAtIndex:i];
                     if([myResponse isKindOfClass:[NSDictionary class]])
                     {
                         NSDictionary *dict = myResponse;
                         NSArray *arrKeys = [dict allKeys];
                         NSMutableArray *arrValues = [[NSMutableArray alloc]init];
                         for (int j=0; j<arrKeys.count; i++)
                         {
                             [arrValues addObject:[dict objectForKey:[arrKeys objectAtIndex:j]]];
                         }


                     }

                }

            }