objective c - How to convert a JSON String into an NSArray? -
i facing issue while converting nsstring nsarray.
my string :
["default", "discipleship", "faith", "family", "hope", "life building", "love", "missions", "relationships"]
what want elements(default,discipleship etc.) out of string , put them nsarray.
i have tried lot couldn't done, please great , in advance
first convert string nsdata:
nsstring* str = @"[\"default\",\"discipleship\",\"faith\",\"family\",\"hope\",\"life building\",\"love\",\"missions\",\"relationships\"]"; nsdata* data = [str datausingencoding:nsutf8stringencoding];
then, use:
nserror *e; nsarray *array = [nsjsonserialization jsonobjectwithdata:data options:nil error:&e];
the object array contains elements of json text.
Comments
Post a Comment