-1

I have a webpage with the code in JSON:

[
    {"url":"event.com","name":"Event name","event":"Event"},
    {"url":"event.com","name":"Event name 2","event":"Event"},
    {"url":"event.com","name":"Event name 3","event":"Event 3sw"}
]

I need this data to be stored in an NSMutableArray, like this, with a loop:

[eventsArray addObject:[NSArray arrayWithObjects:url,name,event, nil]];
[eventsArray addObject:[NSArray arrayWithObjects:url,name,event, nil]];
[eventsArray addObject:[NSArray arrayWithObjects:url,name,event, nil]];

How It's possible, maybe with AFNetworking?

icodebuster
  • 8,890
  • 7
  • 62
  • 65
Daniel Campos
  • 971
  • 4
  • 11
  • 20

2 Answers2

1

There are many different JSON Parsers. Apple provides one called NSJSONSerialization

Check here for a very similar question:

How to use NSJSONSerialization

Or the docs:

http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html

Community
  • 1
  • 1
utahwithak
  • 6,235
  • 2
  • 40
  • 62
  • That doesn't answer his question. He wants the data in Foundation objects structured differently than the JSON. – Aaron Brager Jul 17 '13 at 17:07
  • How I can do it using AFNetworking library ? – Daniel Campos Jul 17 '13 at 18:52
  • looks like they have it built in. Follow the examples here:http://cocoadocs.org/docsets/AFNetworking/1.3.1/Classes/AFJSONRequestOperation.html Here is an example of them getting a json object https://github.com/AFNetworking/AFNetworking/wiki/Getting-Started-with-AFNetworking#download-and-parse-json – utahwithak Jul 17 '13 at 19:29
0

While you can of course create your own JSON parser, I don't think it would be a good idea. Here is a github repository for an Objective-C JSON parser

https://github.com/stig/json-framework/

Read the documentation and you should be good to go

rdelfin
  • 819
  • 2
  • 13
  • 31