Related
I'm sending a request about an user. There are several possibilities. I'm thinking about sending a JSON like that:
"type1": {
"id": 34,
"email": "email#test.com",
"firstname": "Juan",
"lastname": "Ito",
"gender": 2,
"created_at": "2012-09-21T18:53:02Z",
"updated_at": "2012-12-27T16:22:47Z"
}
"type2": {
"id": 34,
"email": "email#test.com",
"firstname": "Juan",
"lastname": "Ito",
"gender": 2,
"created_at": "2012-09-21T18:53:02Z",
"updated_at": "2012-12-27T16:22:47Z"
}
"type3": {
"id": 34,
"email": "email#test.com",
"firstname": "Juan",
"lastname": "Ito",
"gender": 2,
"created_at": "2012-09-21T18:53:02Z",
"updated_at": "2012-12-27T16:22:47Z"
}
Then I was thinking about a multiple RKResponseDescriptor but I don't know how to interpret the RKMappingResult. Do I have a way to refer an object to the keyPath ? Here I'm using 3 times the same RKEntityMapping but with different keyPaths.
Finally I don't even know if it's possible.
Edit:
Maybe this kind of JSON is better and easier to understand/map.
"type" : "type1",
"user": {
"id": 34,
"email": "email#test.com",
"firstname": "Juan",
"lastname": "Ito",
"gender": 2,
"created_at": "2012-09-21T18:53:02Z",
"updated_at": "2012-12-27T16:22:47Z"
}
Thank you for your help.
There isn't enough information to suggest about JSON structure. The arbitrary keys isn't very nice, but it is quite common. Generally a 'container' object in the JSON is nicer.
That said, RestKit can generally handle both. Check out addAttributeMappingFromKeyOfRepresentationToAttribute: and addAttributeMappingToKeyOfRepresentationFromAttribute: on RKObjectMapping for examples of how to handle that kind of JSON.
If your question is related to how to map the response JSON using Restkit mapping then this is better way to design your JSON.
{"userProfile":[
{
"id": 34,
"email": "email#test.com",
"firstname": "Juan",
"lastname": "Ito",
"gender": 2,
"created_at": "2012-09-21T18:53:02Z",
"updated_at": "2012-12-27T16:22:47Z"
},
{
"id": 34,
"email": "email#test.com",
"firstname": "Juan",
"lastname": "Ito",
"gender": 2,
"created_at": "2012-09-21T18:53:02Z",
"updated_at": "2012-12-27T16:22:47Z"
},
{
"id": 34,
"email": "email#test.com",
"firstname": "Juan",
"lastname": "Ito",
"gender": 2,
"created_at": "2012-09-21T18:53:02Z",
"updated_at": "2012-12-27T16:22:47Z"
}
]}
Modal classes:
userProfile.h
#property(nonatomic,strong) NSMutableArray *userInfo;
userInfo.h
#property(assign) int id;
#property(nonatomic,strong) NSString *email;
.......
Mapping can be done with AttributeMapping and RelationshipMapping
I finally mapped the type like this:
RKObjectMapping *typeMapping = [RKObjectMapping requestMapping];
[typeMapping addAttributeMappingsFromDictionary:#{#"type":#"type"}];
With this descriptor:
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:typeMapping
method:RKRequestMethodAny
pathPattern:nil
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
Basically to catch this dictionary, basically I did this:
NSString *type = [((NSDictionary *)[[mappingResult array] objectAtIndex:0]) objectForKey:#"type"];
This solve my problem because just after I'm selecting different actions according to the value of type.
I let #Wain tell us if this method is acceptable or not.
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.
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"]);
I have the following JSON:
{
"users": [
{"id": "1", "name": "John Doe"},
{"id": "2", "name": "Bill Nye"}
],
"groups": [
{"id": "1", "name": "Group1", "users": ["1", "2"]},
{"id": "2", "name": "Group2", "users": ["1"]}
]
}
...and a Core Data model with User and Group objects. The group object has a to-many relationship (NSSet) to users.
I have found the following thread that seems to indicate that this is possible, but contains no explanation of how such a mapping is to be performed:
https://github.com/RestKit/RestKit/issues/284
How do I perform this mapping such that each Group's "users" relationship is properly connected?
Note: I have mappings set up that correctly map the JSON users and groups to their respective Core Data objects. However, each group's "users" NSSet is empty.
So, I figured this out using RestKit 0.20(pre2).
JSON needed to be changed to the following (note the attribute names in the group's users array):
{
"users": [
{"id": "1", "name": "John Doe"},
{"id": "2", "name": "Bill Nye"}
],
"groups": [
{"id": "1", "name": "Group1", "users": [{"id" : "1"}, {"id" : "2"}]},
{"id": "2", "name": "Group2", "users": [{"id" : "1"}]}
]
}
Then, the following mappings:
RKEntityMapping *userMapping = [RKEntityMapping mappingForEntityForName:#"User" inManagedObjectStore:managedObjectStore];
userMapping.identificationAttributes = #[#"id"];
[userMapping addAttributeMappingsFromArray:#[#"id", #"name"]];
RKEntityMapping *groupMapping = [RKEntityMapping mappingForEntityForName:#"Group" inManagedObjectStore:managedObjectStore];
groupMapping.identificationAttributes = #[#"id"];
[groupMapping addAttributeMappingsFromArray:#[#"id", #"name"]];
[groupMapping addRelationshipMappingWithSourceKeyPath:#"users" mapping:userMapping];
And finally, the following responseDescriptors:
RKResponseDescriptor *userResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:classMapping pathPattern:#"/api/allthejson" keyPath:#"users" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
RKResponseDescriptor *groupResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:classMapping pathPattern:#"/api/allthejson" keyPath:#"groups" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptorsArray:#[userResponseDescriptor, groupResponseDescriptor]];
Then get your objects using RKObjectManager's getObjectsAtPath:parameters:success:failure method and your done!
RestKit has many issues especially when it comes to modeling relationships. Debugging the mappings can be daunting.
Here is some code that deals with what you describe without RestKit.
NSArray *userArray;
// an array populated with NSManagedObjects
// correctly converted from JSON to the User entity
NSArray *groups = [jsonObject objectForKey:#"groups"];
for (NSDictionary *d in groups) {
Group *g = [NSEntityDescription insertNewObjectForEntityForName:#"Group"
inManagedObjectContext:_managedObjectContext];
g.id = #([d[#"id"] intValue]);
g.name = d[#"name"];
NSArray *users = d[#"users"];
for (NSString *s in users) {
User *u = [[userArray filteredArrayUsingPredicate:
[NSPredicate predicateWithFormat:#"id = %#", #([s intValue])]]
objectAtIndex:0];
[g addUsersObject:u];
}
}
// save
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