hacker
hacker

Reputation: 8947

How to parse an array?

I have an application in which I am getting a response like this from a webservice. Can anybody tell me how to parse this to make it as individual strings"Info":

{
  "name":"gdgdgdgd",
  "desc":"Cosmopolitan life, adventurous outlook, 'been there done that' attitude, and yet the way the life ...",
  "address1":" 2nd A Main ",
  "address2":" Layout,"
},

Upvotes: 0

Views: 67

Answers (2)

hacker
hacker

Reputation: 8947

do like this using json library

NSMutableDictionary *listd=[dict objectForKey:@"merchantInfo"];

if([listd isKindOfClass:[NSDictionary class]])

{

   stringshopname=[listd objectForKey:@"name"]; 
   stringshopdesc=[listd objectForKey:@"desc"];


}

Upvotes: -1

bryanmac
bryanmac

Reputation: 39296

That's a JSON representation of an object.

In iOS 5, JSON classes we're added as NSJSONSerialization

Here's a tutorial:

http://www.raywenderlich.com/5492/working-with-json-in-ios-5

Here's another thread discussing other options as well like JSONKit, YAJL

Native JSON support in iOS?

Upvotes: 2

Related Questions