-2

I'm having some problems in parsing some data from a JSON to a NSDictionary, the data the JSON has inside follows the pattern:

    object =     (
            {
        "field1" = 2;
        "field2" = "something";
        array =             {
            "field3" = "anotherThing";
            booleanField = true;
           {
            };
            otherThing = "yay";
        };    
            },
         {
        "field1" = 2;
        "field2" = "something";
        array =             {
            "field3" = "anotherThing";
            booleanField = true;
           {
            };
            otherThing = "yay";
        };    
            } )     

How can I create a NSArray with 2 NSDictionaries?

I expect I explained it simply

Thank you for your help

Kampai
  • 22,848
  • 21
  • 95
  • 95
Flavio Silverio
  • 1,004
  • 8
  • 12

2 Answers2

0
NSError *jsonParsingError = nil;
NSArray *contentArray = [NSJSONSerialization
                         JSONObjectWithData:[aContentString dataUsingEncoding:NSUTF8StringEncoding]
                         options:0
                         error:&jsonParsingError];  

Hope it helps.

l0gg3r
  • 8,864
  • 3
  • 26
  • 46
-1

Possible duplicate (How to convert JSON serialized data to NSDictionary)

if your response is object = (...);

NSError *err;
NSDictionary *dictObject = [NSJSONSerialization JSONObjectWithData:yourData options:NSJSONReadingMutableContainers error:&err];
NSArray *arr = dictObject[@"object"];

if your response is (...);

NSError *err;
NSArray *arrObject = [NSJSONSerialization JSONObjectWithData:yourData options:NSJSONReadingMutableContainers error:&err];

Maybe it will help you.

Community
  • 1
  • 1
ChintaN -Maddy- Ramani
  • 5,156
  • 1
  • 27
  • 48