JSON parsing Array in iOS with JSONKit - an array without a tag for ObjectForKey?

I am trying to parse a JSON array returned by a RESTful web API that looks like the following (using JSONKit):

[ { "DateCreated" : "/Date(1320296400000)/",
    "ID" : 1,
    "Summary" : "Summary 1",
    "Title" : "Title 1",
    "URL" : "URL 1"
  },
  { "DateCreated" : "/Date(1320296400000)/",
    "ID" : 2,
    "Summary" : "Summary 2",
    "Title" : "Title 2",
    "URL" : "URL 2"
  }
]

The JSON I worked with in the past usually had a parent element, for example news:{{node1},{node2}}, that would allow me to extract this node from the JSON response, for example:

NSString *response = [request responseString];
NSDictionary *deserializedData = [response objectFromJSONString];
NSArray *arrNews = [deserializedData objectForKey:@"news"];

There is no such node in my JSON, it is just a raw array. How do I pull this into an NSArray (or something that I can hook into a UITableView)?

+5
source share
2 answers

JSON, , deserializedData​​strong > JKArray, JKDictionary.

, ?

for (NSDictionary * dataDict in deserializedData) {
    NSString * timeStamp = [dataDict objectForKey:@"DateCreated"];
    // and so on
}

JSON.

+10

JSON "" , / "". JSON "". .

, , , , .

+1

All Articles