-1

Here is a json:

{
  query_list: [
    {
      restaurant: {},
      foods: [
        food1: {},
        food2: {}
      ]
    },
    {
      restaurant: {},
      foods: [
        food3: {},
        food4: {}
      ]
    }
  ],
  url: ""
}

I want use Mantle to map it to:

@property NSString *url
@property NSArray<Foods *> *list

the list need to contains all foods. In this case, foods are food1 food2 food3 food4.

So how to get all foods, combine them to a new array which map to the property list

merito
  • 465
  • 4
  • 15

2 Answers2

0

Based on your JSON formate you have to done below thing to get all food object in single list :

 NSMutableArray * mutArrayFoods = [[NSMutableArray alloc] init];

 for (QueryList *objQueryList in objParseData.queryList) {
      [mutArrayFoods addObjectsFromArray:objQueryList.foods];
 }

Hope this will help to get all foods in single array.

Now as per your request assign this above array into list

list = [mutArrayFoods mutableCopy];
CodeChanger
  • 7,953
  • 5
  • 49
  • 80
0

I change your "Pseudo json code" many times. Maybe your thinking like this:

enter image description here

I try my best to create a model called "HF" for helping you: enter image description here

enter image description here

Qun Li
  • 1,256
  • 13
  • 13