Parsing JSON and get the values [duplicate] - objective-c

I have the following JSON:
{
"meta": {
"code": 200
},
"response": {
"deals": [
{
"id": 32373,
"date_added": "2011-01-13 12:12:50",
"end_date": "2011-01-14 10:00:00",
"active": 1,
"discount": {
"raw": 71,
"formatted": "71%"
},
"price": {
"raw": "85.00",
"formatted": "$85"
},
"value": {
"raw": "300.00",
"formatted": "$300"
},
"purchased": 82,
"left": null,
"title": "$85 For $300 Babyface Facial At Park Avenue MedSpa",
"yipit_title": "71% off Babyface Facial",
"url": "http://yipit.com/aff/click/?deal=AvwTADtE&key=F374EFbM",
"yipit_url": "http://yipit.com/new-york/livingsocial/85-for-300-babyface-facial-at-park-avenue-medspa/",
"images": {
"image_big": "http://d22nv2k05ynu7x.cloudfront.net/deal_images/deal/85-for-300-babyface-facial-at-park-avenue-medspa-1294920769_display_image.jpg",
"image_small": "http://d22nv2k05ynu7x.cloudfront.net/deal_images/deal/85-for-300-babyface-facial-at-park-avenue-medspa-1294920769_small_image.jpg"
},
"division": {
"slug": "new-york",
"name": "New York",
"active": 1,
"time_zone_diff": -4,
"lat": "40.7142690000000000",
"lon": "-74.0059730000000000",
"url": "http://yipit.com/new-york/"
},
"tags": [
{
"name": "Facial",
"slug": "facial",
"url": "http://yipit.com/new-york/deals/facial/"
},
{
"name": "Spa",
"slug": "spa",
"url": "http://yipit.com/new-york/deals/spa/"
}
],
"business": {
"name": "Park Avenue MedSpa",
"url": "",
"locations": [
{
"address": "565 Park Ave",
"locality": "New York",
"phone": "212-593-8821",
"lat": null,
"lon": null
}
]
},
"source": {
"name": "LivingSocial",
"slug": "livingsocial",
"paid": 0,
"url": "http://yipit.com/new-york/livingsocial"
}
}
]
}
}
Here is how I am parsing it:
NSArray *deals = [[results objectForKey:#"response"] valueForKey:#"deals"];
NSLog(#"%#",[[results objectForKey:#"response"] valueForKey:#"deals"]);
for(NSDictionary* deal in deals)
{
NSLog(#"Title: %#", [deal valueForKey:#"title"]);
NSLog(#"URL: %#", [deal valueForKey:#"url"]);
NSLog(#"Value: %#", [[deal valueForKey:#"value"] valueForKey:#"formatted"]);
NSLog(#"Picture URL: %#", [[deal valueForKey:#"images"] valueForKey:#"image_small"]);
NSLog(#"Business: %#", [[deal valueForKey:#"business"] valueForKey:#"name"]);
NSLog(#"Address: %#", [[[deal valueForKey:#"business"] valueForKey:#"locations"] valueForKey:#"address"]);
NSLog(#"City: %#", [[[deal valueForKey:#"business"] valueForKey:#"locations"] valueForKey:#"locality"]);
NSLog(#"Phone: %#", [[[deal valueForKey:#"business"] valueForKey:#"locations"] valueForKey:#"phone"]);
[items addObject:deal];
}
My logging looks good except for Address, City and Phone. Here is the log:
Title: $10 for $20 Worth of Food and Drinks at Blondies in Tempe
URL: http://yipit.com/aff/click/?deal=cHBPNZ3w&key=93HU7t2d
Value: $20
Picture URL: http://d22nv2k05ynu7x.cloudfront.net/deal_images/deal/50-off-at-blondies-sports-bar-1298454745_small_image.jpg
Business: Blondies Sports Bar
Address: (
"501 S Mill Ave"
)
City: (
Tempe
)
Phone: (
"702-737-0444"
)

From the JSON you provided, locations is an array (that's what the square brackets mean), so the values that are returned from valueForKey: are contained in NSArray instances (hence the parentheses).
You could use objectAtIndex: before the last call to valueForKey: to obtain just the value you're looking for.
By the way, you can also use valueForKeyPath: to simplify accessing nested values, for example
[deal valueForKeyPath:#"business.name"];

[[deal valueForKey:#"business"] valueForKey:#"locations"] returns an array. Calling -valueForKey: on an NSArray executes valueForKey: for every object in the array and returns an array of the results (see the NSArray documentation for this). So that's what you get, an array of the corresponding values.

You could try changing your code to something like this:
NSDictionary *primaryLocation = [[[deal valueForKey:#"business"] valueForKey:#"locations"] objectAtIndex:0];
NSLog(#"Address: %#", [primaryLocation valueForKey:#"address"]);
NSLog(#"City: %#", [primaryLocation valueForKey:#"locality"]);
NSLog(#"Phone: %#", [primaryLocation valueForKey:#"phone"]);

Related

How to map an array of arrays in Mantle

Anybody got an idea of how to map this response to a mantle object?
I need to get these to an NSArray of custom classes. But the Mantle documentation has no mention on how to do this.
Thanks in advance.
[
[
{
"plu_id": "1744",
"name": "With egg",
"price": "2.00",
"group": null
}
],
[
{
"plu_id": "1745",
"name": "add roast chicken",
"price": "3.00",
"group": "1"
},
{
"plu_id": "1749",
"name": "add beef",
"price": "4.00",
"group": "1"
}
]
]
Please try the below snippet mentioned for an identical issue
+ (NSValueTransformer *)allRowsJSONTransformer
{
return [MTLValueTransformer transformerWithBlock:^id(NSArray *inSectionJSONArray) {
NSMutableArray *sectionArray = [[NSMutableArray alloc] initWithCapacity:inSectionJSONArray.count];
for( NSArray *section in inSectionJSONArray )
{
NSError *error;
NSArray *cardItemArray = [MTLJSONAdapter modelsOfClass:[CKMCardItem class] fromJSONArray:section error:&error];
if( cardItemArray != nil )
{
[sectionArray addObject:cardItemArray];
}
}
return sectionArray;
}];
}

What is the closest equivalent in Objective-C for "data.response.venues[0].name" when trying to get a specific value from a JSON response?

I have a json string from the Foursquare venues API (see below). It's in the form of an NSData object from the following code:
NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response,
NSData *data, NSError *connectionError)
I'd like to retreive the name of the first venue in the json. I find myself wanting to type "data.response.venues[0].name". Does Objective C have something similar to this one-line syntax for grabbing a specific value from an NSData object?
JSON
{
"meta": {
"code": 200
},
"response": {
"venues": [{
"id": "503de4dce4b0857b003af5f7",
"name": "monkeyHut",
"contact": {},
"location": {
"lat": 40.7,
"lng": -74.0,
"distance": 0,
"postalCode": "10004",
"cc": "US",
"city": "New York",
"state": "NY",
"country": "United States",
"formattedAddress": ["New York, NY 10004", "United States"]
},
"categories": [{
"id": "4bf58dd8d48988d1e1931735",
"name": "Arcade",
"pluralName": "Arcades",
"shortName": "Arcade",
"icon": {
"prefix": "https:\/\/ss1.4sqi.net\/img\/categories_v2\/arts_entertainment\/arcade_",
"suffix": ".png"
},
"primary": true
}],
"verified": false,
"stats": {
"checkinsCount": 24,
"usersCount": 16,
"tipCount": 4
},
You first need to parse the JSON response data in the NSData object to actual Cocoa dictionary/array objects (available from iOS 5.0):
NSError *error = nil;
NSDictionary *object = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if (error != nil) {
NSLog(#"Invalid response");
return;
}
You can then use objectForKey:/objectAtIndex: or their literal variants as shown below to access the data:
NSString *name = object[#"response"][#"venues"][0][#"name"];
DO NOT use this code directly, because a JSON response with another layout than you expect (e.g. data.response is changed from a dictionary to an array) will cause a runtime error when trying to use an object as a dictionary, when it actually is an object of another type. You can check the type of your objects using the following:
if ([object isKindOfClass:[NSDictionary class]]) {
}

Error when mapping with RestKit

Im making an application that gets 3 JSON from a Wordpress site, then it maps them in 3 different classes: Products, Locations and Categories, the Products and Categories mapping works just fine, but when Im mapping the Locations it gets mixed with the Products, and causes an error in both, heres my Location class:
#interface Location : NSObject
#property (nonatomic, retain) NSString * alias;
#property (nonatomic, retain) NSSet * street;
#property (nonatomic, retain) NSSet * number;
#property (nonatomic, retain) NSSet * state;
#property (nonatomic, retain) NSSet * city;
#property (nonatomic, retain) NSSet * zipcode;
#property (nonatomic, copy) NSSet * locationId;
#end
and here is the Products class:
#interface AllProducts : NSObject
#property (nonatomic, copy) NSString * name;
#property (nonatomic, copy) NSSet * locationId;
#property (nonatomic, copy) NSSet * productCategoryId;
#property (nonatomic, strong) NSMutableArray *prices;
#end
below is the mapping Im using:
//Products Mapping
RKObjectMapping *productsMapping = [RKObjectMapping mappingForClass:[AllProducts class]];
[productsMapping addAttributeMappingsFromDictionary:#{
#"title": #"name",
#"custom_fields.product_0_sucursal": #"locationId",
/*#"custom_fields.tipo_de_producto": #"productType",
#"custom_fields.product_0_price": #"price",
#"custom_fields.product_0_real_id": #"realId",
#"custom_fields.product_0_size": #"size",
#"custom_fields.product_0_modificador": #"mod",
#"custom_fields.product_0_temperatura": #"temp",*/
#"categories.id": #"productCategoryId"
}];
[productsMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:#"custom_fields"
toKeyPath:#"prices"
withMapping:pricesMapping]];
RKResponseDescriptor *productsResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:productsMapping method:RKRequestMethodAny pathPattern:nil keyPath:#"posts" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptor:productsResponseDescriptor];
//Locations Mapping
RKObjectMapping *locationsMapping = [RKObjectMapping mappingForClass:[Location class]];
[locationsMapping addAttributeMappingsFromDictionary:#{
#"title": #"alias",
#"custom_fields.calle": #"street",
#"custom_fields.numero": #"number",
#"custom_fields.estado": #"state",
#"custom_fields.ciudad": #"city",
#"custom_fields.codigo_postal": #"zipcode",
#"custom_fields.locationid": #"locationId"
}];
RKResponseDescriptor *locationsResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:locationsMapping method:RKRequestMethodAny pathPattern:nil keyPath:#"posts" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptor:locationsResponseDescriptor];
I have the mapping definitions in the AppDelegate, and the call of the objects is in the tableview controllers
For Locations:
RKObjectManager* objectManager = [RKObjectManager sharedManager];
NSDictionary *parameters;
parameters = #{
#"json" : #"get_posts",
#"post_type" : #"locations"
};
[objectManager getObjectsAtPath:#"" parameters:parameters success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
{
_locations = [mappingResult array];
[[self tableView]reloadData];
}
failure:^(RKObjectRequestOperation *operation, NSError *error){
[self handleFailure:operation withError:error];
}];
and for Products:
//Getting all the products
RKObjectManager *objectManager = [RKObjectManager sharedManager];
//Mutable array that will contain the products when a category is selected
_productByCategory = [[NSMutableArray alloc] init];
NSDictionary *parameters;
http://localhost/?json=get_posts&post_type=products
parameters = #{
#"json" : #"get_posts",
#"post_type" : #"products"
};
//Getting all the products and then selecting only the products that are in the category selected
[objectManager getObjectsAtPath:#"" parameters:parameters success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult)
{
_products = [mappingResult array];
NSArray *tempProducts = _products;
//NSString *productToAdd;
BOOL isDuplicate = NO;
for(NSSet *currentProduct in tempProducts)
{
for(NSSet *product in _productByCategory)
{
if ([[currentProduct valueForKey:#"_name"] isEqualToString:[product valueForKey:#"_name"]]){
isDuplicate = YES;
break;
}
}
if(!isDuplicate && [currentProduct valueForKey:#"_name"] != nil && [[currentProduct valueForKey:#"_productCategoryId" ] containsObject:category.categoryId] && [[currentProduct valueForKey:#"_locationid"] containsObject:location.locationId]){
//productToAdd = [[NSString alloc] initWithFormat:#"%#", [currentProduct valueForKey:#"_name"]];
[_productByCategory addObject:currentProduct];
}
/*if([[currentProduct valueForKey:#"_productCategoryId" ] containsObject:category.categoryId])
{
[_productByCategory addObject:currentProduct];
}*/
}
[[self tableView]reloadData];
}
failure:^(RKObjectRequestOperation *operation, NSError *error){
[self handleFailure:operation withError:error];
}];
//update view title
self.title = [category.categoryName lowercaseString];
and below are the JSON for both:
http://localhost/?json=get_posts&post_type=locations
{
"status": "ok",
"count": 2,
"count_total": 2,
"pages": 1,
"posts": [
{
"id": 263,
"type": "locations",
"slug": "sucursal-plaza-regia",
"url": "http://localhost/?locations=sucursal-plaza-regia",
"status": "publish",
"title": "Sucursal Plaza Regia",
"title_plain": "Sucursal Plaza Regia",
"content": "",
"excerpt": "",
"date": "2014-03-25 15:44:29",
"modified": "2014-03-25 15:44:29",
"categories": [],
"tags": [],
"author": {
"id": 1,
"slug": "arturocalvo",
"name": "arturocalvo",
"first_name": "",
"last_name": "",
"nickname": "arturocalvo",
"url": "",
"description": ""
},
"comments": [],
"attachments": [],
"comment_count": 0,
"comment_status": "closed",
"custom_fields": {
"calle": [
"Av. Eugenio Garza Sada"
],
"numero": [
"No. 3720 Local L-3"
],
"estado": [
"Nuevo Leon"
],
"ciudad": [
"Monterrey"
],
"codigo_postal": [
"64780"
],
"locationid": [
"3"
]
}
},
{
"id": 256,
"type": "locations",
"slug": "sucursal-plaza-404-2",
"url": "http://localhost/?locations=sucursal-plaza-404-2",
"status": "publish",
"title": "Sucursal Plaza 404",
"title_plain": "Sucursal Plaza 404",
"content": "",
"excerpt": "",
"date": "2014-03-24 16:58:20",
"modified": "2014-03-24 16:58:20",
"categories": [],
"tags": [],
"author": {
"id": 1,
"slug": "arturocalvo",
"name": "arturocalvo",
"first_name": "",
"last_name": "",
"nickname": "arturocalvo",
"url": "",
"description": ""
},
"comments": [],
"attachments": [],
"comment_count": 0,
"comment_status": "closed",
"custom_fields": {
"calle": [
"Av. Gomez Morin"
],
"numero": [
"404 Local A3-5"
],
"estado": [
"Nuevo Leon"
],
"ciudad": [
"San Pedro Garza Garcia"
],
"codigo_postal": [
"66220"
],
"locationid": [
"2"
]
}
}
],
"query": {
"ignore_sticky_posts": true,
"post_type": "locations"
}
}
{
"status": "ok",
"count": 5,
"count_total": 5,
"pages": 1,
"posts": [
{
"id": 267,
"type": "products",
"slug": "cafe-americano-3",
"url": "http://localhost/?products=cafe-americano-3",
"status": "publish",
"title": "Cafe Americano",
"title_plain": "Cafe Americano",
"content": "",
"excerpt": "",
"date": "2014-03-25 16:55:58",
"modified": "2014-03-25 16:55:58",
"categories": [
{
"id": 1,
"slug": "coffeebar",
"title": "Coffee Bar",
"description": "",
"parent": 0,
"post_count": 3
}
],
"tags": [],
"author": {
"id": 1,
"slug": "arturocalvo",
"name": "arturocalvo",
"first_name": "",
"last_name": "",
"nickname": "arturocalvo",
"url": "",
"description": ""
},
"comments": [],
"attachments": [],
"comment_count": 0,
"comment_status": "closed",
"custom_fields": {
"tipo_de_producto": [
"bebida"
],
"tipo_de_bebida": [
"cafe"
],
"product_0_size": [
"l"
],
"product_0_price": [
"30"
],
"product_0_sucursal": [
"2"
],
"product_0_temperatura": [
"caliente"
],
"product_0_modificador": [
"regular"
],
"product_0_priceid": [
"432"
],
"product": [
"1"
]
}
},
{
"id": 266,
"type": "products",
"slug": "cafe-americano-2",
"url": "http://localhost/?products=cafe-americano-2",
"status": "publish",
"title": "Cafe Americano",
"title_plain": "Cafe Americano",
"content": "",
"excerpt": "",
"date": "2014-03-25 16:55:23",
"modified": "2014-03-25 16:55:23",
"categories": [
{
"id": 1,
"slug": "coffeebar",
"title": "Coffee Bar",
"description": "",
"parent": 0,
"post_count": 3
}
],
"tags": [],
"author": {
"id": 1,
"slug": "arturocalvo",
"name": "arturocalvo",
"first_name": "",
"last_name": "",
"nickname": "arturocalvo",
"url": "",
"description": ""
},
"comments": [],
"attachments": [],
"comment_count": 0,
"comment_status": "closed",
"custom_fields": {
"tipo_de_producto": [
"bebida"
],
"tipo_de_bebida": [
"cafe"
],
"product_0_size": [
"s"
],
"product_0_price": [
"25"
],
"product_0_sucursal": [
"3"
],
"product_0_temperatura": [
"caliente"
],
"product_0_modificador": [
"regular"
],
"product_0_priceid": [
"438"
],
"product": [
"1"
]
}
}
The problem is that when I make the request for only products, it works fine, when i make the request for only locations it works fine too, but when the two are made, location tries to map to products class and products tries to map to location class, and I get an Error, can somebody help me to know what Im doing wrong?, thanks in advance
Because RestKit can't tell the difference between the responses because the path patterns and key paths of both descriptors are identical (all of the difference is in the URL query parameters and they aren't used by RestKit).
So, you either need to change the request URL (and change pathPattern:nil on the response descriptors). Or change the JSON (so you have a different key path). Or delete the response descriptors after each request and recreate only the appropriate one before a request. Or use 2 different object managers, each with only 1 response descriptor.

restkit nested object with array mapping

I have this json:
{
"status": "ok",
"post": {
"id": 171,
"type": "locations",
"slug": "plaza-404",
"url": "http://localhost/?locations=plaza-404",
"status": "publish",
"title": "Sucursal Plaza 404",
"title_plain": "Sucursal Plaza 404",
"content": "",
"excerpt": "",
"date": "2014-03-05 19:59:50",
"modified": "2014-03-07 19:11:43",
"categories": [],
"tags": [],
"author": {
"id": 1,
"slug": "arturocalvo",
"name": "arturocalvo",
"first_name": "",
"last_name": "",
"nickname": "arturocalvo",
"url": "",
"description": ""
},
"comments": [],
"attachments": [],
"comment_count": 0,
"comment_status": "closed",
"custom_fields": {
"id": [
"1"
],
"location_id": [
"1"
],
"calle": [
"Av. Gomez Morin No.404 Local A3-5"
]
}
And i Want to map only the title the custom field called "calle", this is my interface for Location
#interface Location : NSObject
#property (nonatomic, copy) NSString * name;
#property (nonatomic, copy) NSSet * calle;
#end
and this is my code
RKObjectMapping *locationMapping = [RKObjectMapping mappingForClass:[Location class]];
RKObjectMapping *locationCustomMapping = [RKObjectMapping mappingForClass: [LocationCustom class]];
[locationMapping addAttributeMappingsFromDictionary:#{
#"title": #"name",
#"calle": #"calle"
}];
RKResponseDescriptor *locationResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:locationMapping method:RKRequestMethodAny pathPattern:nil keyPath:#"post" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptor:locationResponseDescriptor];
NSURLRequest *request = [NSURLRequest requestWithURL:baseURL];
RKObjectRequestOperation *objectRequestOperation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:#[ locationResponseDescriptor ]];
But for some reason i cant map it, everythime gets a null value, can somebody help me?
You are missing a level in the JSON that you need to tell RestKit to navigate. Use:
#"custom_fields.calle": #"calle"
in your mapping.

Read Specific Character from NSSTRING and save them in NSDictionary (LinkedIn Api)

I am using Linkedin Api in my Iphone App.I want to read the Connection Names and their Profession.In First Step I read the user name and Professional by using the Following Api.
http://api.linkedin.com/v1/people/~
It return the following String and I convert that string in to NSDictionary .Its Work Fine.
====================================
coming string is equql to {
"headline": "Computer Software Professional",
"lastName": "Ahmed",
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=86794265&authToken=ZBFd&authType=name&trk=api*a135617*s143990*"},
"firstName": "Umair"
}
========================================
Nsstring to NSDictionary conversion:-
Data coming from LinkedIn site
NSString *responseBody = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(#"coming string is equql to %#",responseBody);
NSDictionary *profile = [responseBody objectFromJSONString];
[responseBody release];
if ( profile )
{
name.text = [[NSString alloc] initWithFormat:#"%# %#",
[profile objectForKey:#"firstName"], [profile objectForKey:#"lastName"]];
headline.text = [profile objectForKey:#"headline"];
}
The Above code Work Fine.
But when i use Connection Api.(For Linkedin Friends)
http://api.linkedin.com/v1/people/~/connections
I receive the following response in String.
========================================================================================
coming string is equql to {
"values": [
{
"headline": "--",
"id": "jrzlnzmKgH",
"lastName": "ahmad",
"pictureUrl": "http://media.linkedin.com/mpr/mprx/0_7bH7Ex4_zD3EJFYkDFRKEjehBacbMF0kD8prEjV0eIiBQ_HXiT4_XgmAM8BZVhOemkol5sXLbyGk",
"location": {
"name": "United Arab Emirates",
"country": {"code": "ae"}
},
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=87979190&authToken=RO5n&authType=name&trk=api*a135617*s143990*"},
"apiStandardProfileRequest": {
"headers": {
"values": [{
"name": "x-li-auth-token",
"value": "name:RO5n"
}],
"_total": 1
},
"url": "http://api.linkedin.com/v1/people/jrzlnzmKgH"
},
"firstName": "junaid"
},
{
"headline": "Field Testing Engineer at SENSYS",
"id": "iZbYn6whQT",
"lastName": "Ali Ayub",
"location": {
"name": "Pakistan",
"country": {"code": "pk"}
},
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=66010848&authToken=k_Wj&authType=name&trk=api*a135617*s143990*"},
"apiStandardProfileRequest": {
"headers": {
"values": [{
"name": "x-li-auth-token",
"value": "name:k_Wj"
}],
"_total": 1
},
"url": "http://api.linkedin.com/v1/people/iZbYn6whQT"
},
"industry": "Government Administration",
"firstName": "Prince"
},
{
"headline": "Student at comsats",
"id": "AZtfwY31D2",
"lastName": "Anwar",
"location": {
"name": "Pakistan",
"country": {"code": "pk"}
},
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=106573059&authToken=4_ll&authType=name&trk=api*a135617*s143990*"},
"apiStandardProfileRequest": {
"headers": {
"values": [{
"name": "x-li-auth-token",
"value": "name:4_ll"
}],
"_total": 1
},
"url": "http://api.linkedin.com/v1/people/AZtfwY31D2"
},
"industry": "Computer Networking",
"firstName": "Irfan"
},
{
"headline": "WiMAX RF Planning Engineer at IACGRP",
"id": "ERjOSiKbPo",
"lastName": "Arsil",
"pictureUrl": "http://media.linkedin.com/mpr/mprx/0_T_Ic9x0GWkhvZ7R13LHX9juCdb-ZsoI1iC0e9pDY9C6e5mpPD5RRZyMKFdtbJDo088ddJU1s5_py",
"location": {
"name": "Pakistan",
"country": {"code": "pk"}
},
"siteStandardProfileRequest": {"url": "http://www.linkedin.com/profile?viewProfile=&key=35285050&authToken=ouYS&authType=name&trk=api*a135617*s143990*"},
"apiStandardProfileRequest": {
"headers": {
"values": [{
"name": "x-li-auth-token",
"value": "name:ouYS"
}],
"_total": 1
},
"url": "http://api.linkedin.com/v1/people/ERjOSiKbPo"
},
=====================================================
Now I want to convert it in to NsDictionary With key Value Like Firstname,Lastname etc.How can I do This.
Thanks in Advance
You need to use a JSON library for iPhone. One of them is the TouchJSON library, you can see this question to learn more.
Use Json Libraray for Retreive your Values.Its so Simple.Thanks