如何遍历嵌套的json对象数组

如何遍历嵌套的json对象数组,json,flutter,dart,Json,Flutter,Dart,我对Json解析非常陌生。 我必须遍历json数组对象 我的JSON类: class Jsons { static var hotelListJson = { 'hotelData': [ { 'index': 0, 'restaurantName': 'Monginis Cake Shop', 'foodCategory': 'The Cake Shop', 'restReview': 5,

我对Json解析非常陌生。 我必须遍历json数组对象

我的JSON类:

  class Jsons {
  static var hotelListJson = {
    'hotelData': [
      {
        'index': 0,
        'restaurantName': 'Monginis Cake Shop',
        'foodCategory': 'The Cake Shop',
        'restReview': 5,
        'restImage': 'assets/images/Restaurant1.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
        'menuCategories': [
          {
            'categoryName': 'Pastry',
            'dishes': [
              {
                'dishName': 'Dutch Pastry',
                'price': 5,
              },
              {
                'dishName': 'Black Forest pastry',
                'price': 50,
              },
              {
                'dishName': 'Truffle Pastry',
                'price': 35,
              },
              {
                'dishName': 'Dutch Alond Veg',
                'price': 50,
              },
            ]
          },

          {
            'categoryName': 'Breads',
            'dishes': [
              {
                'dishName': 'Sandwich Bread',
                'price': 5,
              },
              {
                'dishName': 'Multigrain Bread',
                'price': 50,
              },
              {
                'dishName': 'Duth Chocolate Heart Veg (Small)',
                'price': 35,
              },
              {
                'dishName': 'Brown Bread',
                'price': 50,
              },
            ]
          },

          
          {
            'categoryName': 'Savouries',
            'dishes': [
              {
                'dishName': 'Panner pattice',
                'price': 5,
              },
              {
                'dishName': 'Veg Burger',
                'price': 50,
              },
              {
                'dishName': 'Pan Pizza Veg',
                'price': 35,
              },
              {
                'dishName': 'Veg pattice',
                'price': 50,
              },
            ]
          },
        ]
      },
      {
        'index': 1,
        'restaurantName': 'Swami Hotel',
        'foodCategory': 'Family Hotel',
        'restReview': 2,
        'restImage': 'assets/images/Restaurant2.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
        'menuCategories': [
          {
            'categoryName': 'Veg Starter',
            'dishes': [
              {
                'dishName': 'Paneer pahadi kabab',
                'price': 5,
              },
              {
                'dishName': 'Garlic chana',
                'price': 50,
              },
              {
                'dishName': 'Masala papad',
                'price': 35,
              },
              {
                'dishName': 'Manchurian',
                'price': 50,
              },
              {
                'dishName': 'Masroom chilli',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Non Veg Starter',
            'dishes': [
              {
                'dishName': 'CHI Chilli Gravy',
                'price': 5,
              },
              {
                'dishName': 'Lollypop Sezwan',
                'price': 50,
              },
              {
                'dishName': 'Pan Pizza Veg',
                'price': 35,
              },
              {
                'dishName': 'Chicken crispy',
                'price': 50,
              },
              {
                'dishName': 'Mandeli fry',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Tandoori',
            'dishes': [
              {
                'dishName': 'Chicken Tandoori',
                'price': 5,
              },
              {
                'dishName': 'Chicken Tangadi Kabab',
                'price': 50,
              },
              {
                'dishName': 'Chicken Pahadi Kabab',
                'price': 35,
              },
              {
                'dishName': 'Chicken Hydrabadi Kabab',
                'price': 50,
              },
              {
                'dishName': 'Mutton Kadhai',
                'price': 50,
              },
            ]
          },
          
          {
            'categoryName': 'NON VEG SOUP',
            'dishes': [
              {
                'dishName': 'Chi manchaow Soup',
                'price': 5,
              },
              {
                'dishName': 'Chi Clear Soup',
                'price': 50,
              },
              {
                'dishName': 'Chi Schezwan Soup',
                'price': 35,
              },
              {
                'dishName': 'Swami Special Chi Soup',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'VEG SOUP',
            'dishes': [
              {
                'dishName': 'Chicken Masala',
                'price': 5,
              },
              {
                'dishName': 'Chicken Tikka Masala',
                'price': 50,
              },
              {
                'dishName': 'Chicken Handi',
                'price': 35,
              },
              {
                'dishName': 'Butter Chicken',
                'price': 50,
              },
              {
                'dishName': 'Mutton Kadhai',
                'price': 50,
              },
            ]
          },
        ]
      },
      {
        'index': 2,
        'restaurantName': 'Smart open pick cake shop',
        'foodCategory': 'Cake Shop',
        'restReview': 1,
        'restImage': 'assets/images/Restaurant4.png',
        'distanceFromLocation': 10,
        'restStatus': 'closed',
        'offer': 'Get 5% discount',
        'menuCategories': [
          {
            'categoryName': 'CAKE HALF Kg',
            'dishes': [
              {
                'dishName': 'Black Forest',
                'price': 300,
              },
              {
                'dishName': 'Pineapple half kg',
                'price': 50,
              },
              {
                'dishName': 'Lichi half kg',
                'price': 35,
              },
              {
                'dishName': 'choco chips half kg',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'CAKE 1 KG',
            'dishes': [
              {
                'dishName': 'Butterscotch',
                'price': 5,
              },
              {
                'dishName': 'Rose falooda',
                'price': 50,
              },
              {
                'dishName': 'White forest ovenpick',
                'price': 35,
              },
              {
                'dishName': 'Mix Fruit',
                'price': 50,
              },
            ]
          },
        ]
      },
      {
        'index': 3,
        'restaurantName': 'Mitarth Chinese',
        'foodCategory': 'Chinese corner',
        'restReview': 3,
        'restImage': 'assets/images/Restaurant5.png',
        'distanceFromLocation': 20,
        'restStatus': 'open',
      },
      {
        'index': 4,
        'restaurantName': 'Selfie Chat',
        'foodCategory': 'Paani Puri & more',
        'restReview': 2,
        'restImage': 'assets/images/Restaurant6.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
      },
      {
        'index': 5,
        'restaurantName': 'Gareeb Nawaj Biryani',
        'foodCategory': 'Caterers Biryani',
        'restReview': 5,
        'restImage': 'assets/images/Restaurant7.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
      },
      {
        'index': 6,
        'restaurantName': 'Prem Sweets',
        'foodCategory': 'Sweets shop',
        'restReview': 1,
        'restImage': 'assets/images/Restaurant8.png',
        'distanceFromLocation': 40,
        'restStatus': 'closed',
        'offer': 'Get 5% discount',
      }
    ]
  };
}
基本上,我所做的是abc是一家酒店的名称,abc的子类别列表填充在其中。子类别也有类型列表

问题是在那家酒店下面可能有很多种类型。所以我需要在Dart中有一个适当的循环结构,它可以是通用的来处理它

我已成功解析主数组,但无法解析子类别和子类别下的类型

这就是我迭代的方式:

  @override
  void initState() {
    super.initState();
    for (int i = 0; i < (Jsons.hotelListJson['hotelData'].length); i++) {
      var currObj = Jsons.hotelListJson['hotelData'][i];
      var currObjSubCategoryList =
          currObj['menuCategories'] as List<Map<String, Object>>;
      for (int j = 0; j < currObjSubCategoryList.length; j++) {
        var listItem = currObjSubCategoryList[j];
        var typeList = listItem['categoryName'] as List<Map<String, Object>>;
        for (int k = 0; k < typeList.length; k++) {
          var temp = typeList[k];
          var currTypeName = temp['dishes'];
          print(currTypeName);
          restaurantListModel.add(RestaurantListModel(
            currObj['restaurantName'],
            currObj['foodCategory'],
            currObj['restReview'],
            currObj['restImage'],
            currObj['distanceFromLocation'],
            currObj['restStatus'],
          ));
        }
      }
    }
  }
请帮忙


提前感谢。

这就是我对列表长度进行迭代的意思,我添加了一段代码,您可以从中了解如何解析

更新代码

class Jsons {
  static var hotelListJson = {
    'hotelData': [
      {
        'index': 0,
        'restaurantName': 'Monginis Cake Shop',
        'foodCategory': 'The Cake Shop',
        'restReview': 5,
        'restImage': 'assets/images/Restaurant1.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
        'menuCategories': [
          {
            'categoryName': 'Pastry',
            'dishes': [
              {
                'dishName': 'Dutch Pastry',
                'price': 5,
              },
              {
                'dishName': 'Black Forest pastry',
                'price': 50,
              },
              {
                'dishName': 'Truffle Pastry',
                'price': 35,
              },
              {
                'dishName': 'Dutch Alond Veg',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Breads',
            'dishes': [
              {
                'dishName': 'Sandwich Bread',
                'price': 5,
              },
              {
                'dishName': 'Multigrain Bread',
                'price': 50,
              },
              {
                'dishName': 'Duth Chocolate Heart Veg (Small)',
                'price': 35,
              },
              {
                'dishName': 'Brown Bread',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Savouries',
            'dishes': [
              {
                'dishName': 'Panner pattice',
                'price': 5,
              },
              {
                'dishName': 'Veg Burger',
                'price': 50,
              },
              {
                'dishName': 'Pan Pizza Veg',
                'price': 35,
              },
              {
                'dishName': 'Veg pattice',
                'price': 50,
              },
            ]
          },
        ]
      },
      {
        'index': 1,
        'restaurantName': 'Swami Hotel',
        'foodCategory': 'Family Hotel',
        'restReview': 2,
        'restImage': 'assets/images/Restaurant2.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
        'menuCategories': [
          {
            'categoryName': 'Veg Starter',
            'dishes': [
              {
                'dishName': 'Paneer pahadi kabab',
                'price': 5,
              },
              {
                'dishName': 'Garlic chana',
                'price': 50,
              },
              {
                'dishName': 'Masala papad',
                'price': 35,
              },
              {
                'dishName': 'Manchurian',
                'price': 50,
              },
              {
                'dishName': 'Masroom chilli',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Non Veg Starter',
            'dishes': [
              {
                'dishName': 'CHI Chilli Gravy',
                'price': 5,
              },
              {
                'dishName': 'Lollypop Sezwan',
                'price': 50,
              },
              {
                'dishName': 'Pan Pizza Veg',
                'price': 35,
              },
              {
                'dishName': 'Chicken crispy',
                'price': 50,
              },
              {
                'dishName': 'Mandeli fry',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Tandoori',
            'dishes': [
              {
                'dishName': 'Chicken Tandoori',
                'price': 5,
              },
              {
                'dishName': 'Chicken Tangadi Kabab',
                'price': 50,
              },
              {
                'dishName': 'Chicken Pahadi Kabab',
                'price': 35,
              },
              {
                'dishName': 'Chicken Hydrabadi Kabab',
                'price': 50,
              },
              {
                'dishName': 'Mutton Kadhai',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'NON VEG SOUP',
            'dishes': [
              {
                'dishName': 'Chi manchaow Soup',
                'price': 5,
              },
              {
                'dishName': 'Chi Clear Soup',
                'price': 50,
              },
              {
                'dishName': 'Chi Schezwan Soup',
                'price': 35,
              },
              {
                'dishName': 'Swami Special Chi Soup',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'VEG SOUP',
            'dishes': [
              {
                'dishName': 'Chicken Masala',
                'price': 5,
              },
              {
                'dishName': 'Chicken Tikka Masala',
                'price': 50,
              },
              {
                'dishName': 'Chicken Handi',
                'price': 35,
              },
              {
                'dishName': 'Butter Chicken',
                'price': 50,
              },
              {
                'dishName': 'Mutton Kadhai',
                'price': 50,
              },
            ]
          },
        ]
      },
      {
        'index': 2,
        'restaurantName': 'Smart open pick cake shop',
        'foodCategory': 'Cake Shop',
        'restReview': 1,
        'restImage': 'assets/images/Restaurant4.png',
        'distanceFromLocation': 10,
        'restStatus': 'closed',
        'offer': 'Get 5% discount',
        'menuCategories': [
          {
            'categoryName': 'CAKE HALF Kg',
            'dishes': [
              {
                'dishName': 'Black Forest',
                'price': 300,
              },
              {
                'dishName': 'Pineapple half kg',
                'price': 50,
              },
              {
                'dishName': 'Lichi half kg',
                'price': 35,
              },
              {
                'dishName': 'choco chips half kg',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'CAKE 1 KG',
            'dishes': [
              {
                'dishName': 'Butterscotch',
                'price': 5,
              },
              {
                'dishName': 'Rose falooda',
                'price': 50,
              },
              {
                'dishName': 'White forest ovenpick',
                'price': 35,
              },
              {
                'dishName': 'Mix Fruit',
                'price': 50,
              },
            ]
          },
        ]
      },
      {
        'index': 3,
        'restaurantName': 'Mitarth Chinese',
        'foodCategory': 'Chinese corner',
        'restReview': 3,
        'restImage': 'assets/images/Restaurant5.png',
        'distanceFromLocation': 20,
        'restStatus': 'open',
      },
      {
        'index': 4,
        'restaurantName': 'Selfie Chat',
        'foodCategory': 'Paani Puri & more',
        'restReview': 2,
        'restImage': 'assets/images/Restaurant6.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
      },
      {
        'index': 5,
        'restaurantName': 'Gareeb Nawaj Biryani',
        'foodCategory': 'Caterers Biryani',
        'restReview': 5,
        'restImage': 'assets/images/Restaurant7.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
      },
      {
        'index': 6,
        'restaurantName': 'Prem Sweets',
        'foodCategory': 'Sweets shop',
        'restReview': 1,
        'restImage': 'assets/images/Restaurant8.png',
        'distanceFromLocation': 40,
        'restStatus': 'closed',
        'offer': 'Get 5% discount',
      }
    ]
  };
}

void main() {
  for (int i = 0; i < (Jsons.hotelListJson['hotelData']!.length); i++) {
    var currObj = Jsons.hotelListJson['hotelData']![i];
    if (currObj.containsKey('menuCategories')) {
          var currObjSubCategoryList =
        currObj['menuCategories'] as List<Map<String, Object>>;
      for (int j = 0; j < currObjSubCategoryList.length; j++) {
        var listItem = currObjSubCategoryList[j];
        var typeList = listItem['dishes']! as List<Map<String, Object>>;
        for (int k = 0; k < typeList.length; k++) {
          var temp = typeList[k];
          var currDishName = temp['dishName'];
          var currDishPrice = temp['price'];
          print("Name: " +
              currDishName.toString() +
              "\n" +
              " Price :" +
              currDishPrice.toString());
        }
      }
    }
  }
}
class-json{
静态变量hotelListJson={
“hotelData”:[
{
“索引”:0,
“餐厅名称”:“Monginis蛋糕店”,
“食品分类”:“蛋糕店”,
“restReview”:5,
“restImage”:“assets/images/Restaurant1.png”,
“distanceFromLocation”:40,
“restStatus”:“打开”,
“菜单分类”:[
{
'类别名称':'糕点',
“菜肴”:[
{
“dishName”:“荷兰糕点”,
"价格":5,,
},
{
“dishName”:“黑森林糕点”,
"价格":50,,
},
{
‘dishName’:‘块菌糕点’,
"价格":35,,
},
{
‘dishName’:‘荷兰阿隆德蔬菜’,
"价格":50,,
},
]
},
{
'类别名称':'面包',
“菜肴”:[
{
“dishName”:“三明治面包”,
"价格":5,,
},
{
“dishName”:“多谷物面包”,
"价格":50,,
},
{
‘dishName’:‘Duth巧克力心形蔬菜(小)’,
"价格":35,,
},
{
“dishName”:“棕色面包”,
"价格":50,,
},
]
},
{
“categoryName”:“Savouries”,
“菜肴”:[
{
“dishName”:“Panner pattice”,
"价格":5,,
},
{
“dishName”:“蔬菜汉堡”,
"价格":50,,
},
{
“dishName”:“Pan Pizza vege”,
"价格":35,,
},
{
“dishName”:“蔬菜肉饼”,
"价格":50,,
},
]
},
]
},
{
“索引”:1,
“餐厅名称”:“斯瓦米酒店”,
“食品分类”:“家庭酒店”,
“restReview”:2,
“restImage”:“assets/images/Restaurant2.png”,
“distanceFromLocation”:40,
“restStatus”:“打开”,
“菜单分类”:[
{
'类别名称':'蔬菜起子',
“菜肴”:[
{
“dishName”:“Paneer pahadi kabab”,
"价格":5,,
},
{
“dishName”:“大蒜香奈儿”,
"价格":50,,
},
{
“dishName”:“Masala papad”,
"价格":35,,
},
{
“dishName”:“满洲人”,
"价格":50,,
},
{
“dishName”:“Masroom辣椒”,
"价格":50,,
},
]
},
{
“categoryName”:“非蔬菜开胃菜”,
“菜肴”:[
{
‘dishName’:‘CHI辣椒肉汁’,
"价格":5,,
},
{
“dishName”:“Lollypop Sezwan”,
"价格":50,,
},
{
“dishName”:“Pan Pizza vege”,
"价格":35,,
},
{
“dishName”:“鸡肉脆皮”,
"价格":50,,
},
{
“dishName”:“Mandeli fry”,
"价格":50,,
},
]
},
{
“categoryName”:“Tandoori”,
“菜肴”:[
{
‘dishName’:‘chickentandoori’,
"价格":5,,
},
{
‘dishName’:‘Tangadi卡巴布鸡’,
"价格":50,,
},
{
“dishName”:“鸡肉帕哈迪卡巴”,
"价格":35,,
},
{
“dishName”:“鸡Hydrabadi Kabab”,
"价格":50,,
},
{
"dishName":"羊肉卡德",,
"价格":50,,
},
]
},
{
“类别名称”:“非蔬菜汤”,
“菜肴”:[
{
“dishName”:“chimanchaow汤”,
"价格":5,,
},
{
‘dishName’:‘池清汤’,
"价格":50,,
},
{
“dishName”:“Chi Schezwan汤”,
"价格":35,,
},
{
‘dishName’:‘Swami特色鸡汤’,
"价格":50,,
},
]
},
{
“类别名称”:“蔬菜汤”,
“菜肴”:[
{
“dishName”:“Chicken Masala”,
"价格":5,,
},
{
“dishName”:“Chicken Tikka Masala”,
"价格":50,,
},
{
"dishName":"Chicken Handi",,
“价格”
Container(
              //height: MediaQuery.of(context).size.height - 450,
              child: NotificationListener<OverscrollIndicatorNotification>(
                onNotification: (overscroll) {
                  overscroll.disallowGlow();
                },
                child: ListView.builder(
                    padding: EdgeInsets.only(
                        top: 10, bottom: 30, left: 15, right: 15),
                    controller: ScrollController(),
                    shrinkWrap: true,
                    itemCount: restaurantListModel.length,
                    itemBuilder: (context, index) {
                      return RestaurantCard(restaurantListModel, index,
                          restaurantListModel[index]);
                    }),
              ),
            )
              Padding(
              padding: const EdgeInsets.all(3.0),
              child: Container(
                alignment: Alignment.centerLeft,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      widget.restaurantListModelObj.restaurantName,
                      style: commonTextStyle(
                          size: 2.4 * SizeConfig.textMultiplier,
                          whichFont: 'bold'),
                    ),
                    Text(
                      widget.restaurantListModelObj.foodCategory,
                      style: commonTextStyle(
                        size: 2 * SizeConfig.textMultiplier,
                      ),
                    )
                  ],
                ),
              ),
            ),
class Jsons {
  static var hotelListJson = {
    'hotelData': [
      {
        'index': 0,
        'restaurantName': 'Monginis Cake Shop',
        'foodCategory': 'The Cake Shop',
        'restReview': 5,
        'restImage': 'assets/images/Restaurant1.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
        'menuCategories': [
          {
            'categoryName': 'Pastry',
            'dishes': [
              {
                'dishName': 'Dutch Pastry',
                'price': 5,
              },
              {
                'dishName': 'Black Forest pastry',
                'price': 50,
              },
              {
                'dishName': 'Truffle Pastry',
                'price': 35,
              },
              {
                'dishName': 'Dutch Alond Veg',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Breads',
            'dishes': [
              {
                'dishName': 'Sandwich Bread',
                'price': 5,
              },
              {
                'dishName': 'Multigrain Bread',
                'price': 50,
              },
              {
                'dishName': 'Duth Chocolate Heart Veg (Small)',
                'price': 35,
              },
              {
                'dishName': 'Brown Bread',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Savouries',
            'dishes': [
              {
                'dishName': 'Panner pattice',
                'price': 5,
              },
              {
                'dishName': 'Veg Burger',
                'price': 50,
              },
              {
                'dishName': 'Pan Pizza Veg',
                'price': 35,
              },
              {
                'dishName': 'Veg pattice',
                'price': 50,
              },
            ]
          },
        ]
      },
      {
        'index': 1,
        'restaurantName': 'Swami Hotel',
        'foodCategory': 'Family Hotel',
        'restReview': 2,
        'restImage': 'assets/images/Restaurant2.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
        'menuCategories': [
          {
            'categoryName': 'Veg Starter',
            'dishes': [
              {
                'dishName': 'Paneer pahadi kabab',
                'price': 5,
              },
              {
                'dishName': 'Garlic chana',
                'price': 50,
              },
              {
                'dishName': 'Masala papad',
                'price': 35,
              },
              {
                'dishName': 'Manchurian',
                'price': 50,
              },
              {
                'dishName': 'Masroom chilli',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Non Veg Starter',
            'dishes': [
              {
                'dishName': 'CHI Chilli Gravy',
                'price': 5,
              },
              {
                'dishName': 'Lollypop Sezwan',
                'price': 50,
              },
              {
                'dishName': 'Pan Pizza Veg',
                'price': 35,
              },
              {
                'dishName': 'Chicken crispy',
                'price': 50,
              },
              {
                'dishName': 'Mandeli fry',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'Tandoori',
            'dishes': [
              {
                'dishName': 'Chicken Tandoori',
                'price': 5,
              },
              {
                'dishName': 'Chicken Tangadi Kabab',
                'price': 50,
              },
              {
                'dishName': 'Chicken Pahadi Kabab',
                'price': 35,
              },
              {
                'dishName': 'Chicken Hydrabadi Kabab',
                'price': 50,
              },
              {
                'dishName': 'Mutton Kadhai',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'NON VEG SOUP',
            'dishes': [
              {
                'dishName': 'Chi manchaow Soup',
                'price': 5,
              },
              {
                'dishName': 'Chi Clear Soup',
                'price': 50,
              },
              {
                'dishName': 'Chi Schezwan Soup',
                'price': 35,
              },
              {
                'dishName': 'Swami Special Chi Soup',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'VEG SOUP',
            'dishes': [
              {
                'dishName': 'Chicken Masala',
                'price': 5,
              },
              {
                'dishName': 'Chicken Tikka Masala',
                'price': 50,
              },
              {
                'dishName': 'Chicken Handi',
                'price': 35,
              },
              {
                'dishName': 'Butter Chicken',
                'price': 50,
              },
              {
                'dishName': 'Mutton Kadhai',
                'price': 50,
              },
            ]
          },
        ]
      },
      {
        'index': 2,
        'restaurantName': 'Smart open pick cake shop',
        'foodCategory': 'Cake Shop',
        'restReview': 1,
        'restImage': 'assets/images/Restaurant4.png',
        'distanceFromLocation': 10,
        'restStatus': 'closed',
        'offer': 'Get 5% discount',
        'menuCategories': [
          {
            'categoryName': 'CAKE HALF Kg',
            'dishes': [
              {
                'dishName': 'Black Forest',
                'price': 300,
              },
              {
                'dishName': 'Pineapple half kg',
                'price': 50,
              },
              {
                'dishName': 'Lichi half kg',
                'price': 35,
              },
              {
                'dishName': 'choco chips half kg',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'CAKE 1 KG',
            'dishes': [
              {
                'dishName': 'Butterscotch',
                'price': 5,
              },
              {
                'dishName': 'Rose falooda',
                'price': 50,
              },
              {
                'dishName': 'White forest ovenpick',
                'price': 35,
              },
              {
                'dishName': 'Mix Fruit',
                'price': 50,
              },
            ]
          },
        ]
      },
      {
        'index': 3,
        'restaurantName': 'Mitarth Chinese',
        'foodCategory': 'Chinese corner',
        'restReview': 3,
        'restImage': 'assets/images/Restaurant5.png',
        'distanceFromLocation': 20,
        'restStatus': 'open',
      },
      {
        'index': 4,
        'restaurantName': 'Selfie Chat',
        'foodCategory': 'Paani Puri & more',
        'restReview': 2,
        'restImage': 'assets/images/Restaurant6.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
      },
      {
        'index': 5,
        'restaurantName': 'Gareeb Nawaj Biryani',
        'foodCategory': 'Caterers Biryani',
        'restReview': 5,
        'restImage': 'assets/images/Restaurant7.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
      },
      {
        'index': 6,
        'restaurantName': 'Prem Sweets',
        'foodCategory': 'Sweets shop',
        'restReview': 1,
        'restImage': 'assets/images/Restaurant8.png',
        'distanceFromLocation': 40,
        'restStatus': 'closed',
        'offer': 'Get 5% discount',
      }
    ]
  };
}

void main() {
  for (int i = 0; i < (Jsons.hotelListJson['hotelData']!.length); i++) {
    var currObj = Jsons.hotelListJson['hotelData']![i];
    if (currObj.containsKey('menuCategories')) {
          var currObjSubCategoryList =
        currObj['menuCategories'] as List<Map<String, Object>>;
      for (int j = 0; j < currObjSubCategoryList.length; j++) {
        var listItem = currObjSubCategoryList[j];
        var typeList = listItem['dishes']! as List<Map<String, Object>>;
        for (int k = 0; k < typeList.length; k++) {
          var temp = typeList[k];
          var currDishName = temp['dishName'];
          var currDishPrice = temp['price'];
          print("Name: " +
              currDishName.toString() +
              "\n" +
              " Price :" +
              currDishPrice.toString());
        }
      }
    }
  }
}