-1

I have a dict who look like that:

{
    "from": 0,
    "to": 1412045889232,
    "series": [
        {
            "component": "Table",
            "points": [
                {
                    "ts": "1409745374148", //time stamps
                    "value": "34"
                },
                {
                    "ts": "1409745564148",
                    "value": "36"
                }
            ]
        }
 {
            "component": "Table2",
            "points": [
                {
                    "ts": "1409745374148", //time stamps
                    "value": "43"
                },
                {
                    "ts": "1409745564148",
                    "value": "39"
                }
            ]
        }
    ]
}

i can get the from and to easily. the series also:

NSLog(@"/n Fetched component = %@", [[dict objectForKey:@"series"] valueForKey:@"component"] );
NSLog(@"/n Fetched points = %@", [[dict objectForKey:@"series"] valueForKey:@"points"] );

What i want is getting the value for a define ts any idea?

rebello95
  • 8,486
  • 5
  • 44
  • 65
Nico
  • 93
  • 5
  • Possible duplicate of: http://stackoverflow.com/questions/5547311/how-do-i-parse-json-with-objective-c – Zane Helton Oct 01 '14 at 03:38
  • the dictionnary is actually not made at all similar i'm trying to get it but it isn't like 1{...}2{...} but like "component": "Table", "points": [...} – Nico Oct 01 '14 at 03:56

1 Answers1

2
  NSDictionary *jsonDictionary  ; // Contains Json Serialized Data
    NSArray *seriesArray = [jsonDictionary valueForKey:@"series"];


    for (NSDictionary *innerDictionary in seriesArray)
    {
        NSLog(@"%@" ,[innerDictionary valueForKey:@"component"]);


        for (NSDictionary *pointsDict in [innerDictionary valueForKey:@"points"])
        {
            NSLog(@"%@" , [pointsDict valueForKey:@"ts"]);
        }

    }
neo D1
  • 1,710
  • 13
  • 15