Search code examples
iosasp.netjsonnsjsonserialization

getting boolean or string from ASP.NET Web API via IOS


I can get the value in JSON format with the function:

NSMutableArray *jsonArrayClass = [NSJSONSerialization JSONObjectWithData:data
                                                     options:kNilOptions
                                                       error:&error];

But i really have no idea how to get the string value or boolean value. we have some validation will return this data type. not JSON.

The raw value shown on Flidder looks like (ID00001 is the return string):

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 07 Apr 2014 17:15:28 GMT
Content-Length: 9

"ID00001"

Solution

  • Try this

    [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];