How can i fetch value from Json response in Objective -C

前端 未结 6 757
时光取名叫无心
时光取名叫无心 2021-02-11 11:40

I have a problem with fetching data from Json response.

Here is an example data structure :

(
     {
        AT = \"\";
        DId = 0;
            


        
6条回答
  •  北海茫月
    2021-02-11 12:17

    Try this...

    NSError *error;
    Array1 = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
    
    for(int i=0;i<[Array1 count];i++)
    {
        NSDictionary *dict1 = [Array1 objectAtIndex:i];
    
        ATArray =[dict1 valueForKey:@"AT"];
        DIdArray =[dict1 valueForKey:@"DId"];
        DOArray =[dict1 valueForKey:@"DO"];
        PLIdArray =[dict1 valueForKey:@"PLId"];
    
        etc...
    
        Array2=[dict1 valueForKey:@"PdCatList"];
    
        for(int i=0;i<[Array2 count];i++)
        {
    
            NSDictionary *dict2 = [Array2 objectAtIndex:i];
    
            PLIdArray =[dict2 valueForKey:@"PLId"];
            PPCIdArray =[dict2 valueForKey:@"PPCId"];
    
            etc…
    
            Array3=[dict2 valueForKey:@"pdList"];
    
            for(int i=0;i<[Array3 count];i++)
            {
    
                NSDictionary *dict3 = [Array3 objectAtIndex:i];
    
                IsDisArray =[dict3 valueForKey:@"IsDis"];
                IsPSArray =[dict3 valueForKey:@"IsPS"];
                IsTArray =[dict3 valueForKey:@"IsT"];
                PAArray =[dict3 valueForKey:@"PA"];
                PCIdArray =[dict3 valueForKey:@"PCId"];
            }
        }
    }
    

提交回复
热议问题