0
list = ({
    clouds = 24;
    speed = "4.31";
    temp = {
        day = "283.84";
        eve = "283.84";
        night = "283.84";
    };
}),

Please can anyone tell me what am I doing wrong - I want to display list-->temp-->day value in table first I am trying to get data in an array which is terminating. Here is my code am I doing any wrong

NSDictionary *json = [NSJSONSerialization JSONObjectWithData:dataBuffer options:-1 error:nil];

NSLog(@"%@",json);

NSMutableDictionary * list = [json objectForKey:@"list"];

NSMutableArray *arrays = [[NSMutableArray alloc]initWithCapacity:0];

for (NSDictionary *lists in [list allValues]) {
    [arrays addObject:[list valueForKey:@"temp"]];
}

2 Answers 2

1

If you want to access day then use below line,

NSString *day = [json valueForKeyPath:@"list.temp.day"];
Sign up to request clarification or add additional context in comments.

1 Comment

Then you should accept the answer by clicking arrow button near by answer.
0

Your list is an array, so if you want to do your things without changing much, you can replace:

NSMutableDictionary * list = [json objectForKey:@"list"];

With:

NSMutableDictionary * list = [[json objectForKey:@"list"] objectAtIndex:0];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.