0

I've never used JSON before so I'm not familiar with its syntax.

At the moment I have multiple arrays containing different pieces of data.

I would like to create one JSON object, that contains the multiple arrays each with several pieces of data. E.g. An object called HotelList, containing multiple arrays each for a different name of Hotels. see the example :

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': [
              'Dutch Pastry',
              'Truffle Pastry',
              'Pipeapple Veg Pastry',
              'Brownee Sqare Veg Pastry',
              'Choco Lava Veg Cup'
            ],
          },
          {
            'categoryName': 'small cake ( half kg)',
            'dishes': [
              'Sapphire Veg Small',
              'Deviles Delite Veg Small',
              'Duth Chocolate Heart Veg (Small)',
              'Shimmer Choco Veg Small'
            ]
          },
          {
            'categoryName': 'Breads',
            'dishes': ['Sandwich Bread', 'Multigrain Bread', 'Brown Bread']
          },
          {
            'categoryName': 'Large cake',
            'dishes': ['Alpine Choco Veg(Large)']
          },
          {
            'categoryName': 'Cookies',
            'dishes': [
              'Almond Cocos Cookies',
              'Shewsburry Cookies',
              'Honey Crunch Cookis',
              'Kesar Cookies',
              'Jeeraa Cookies'
            ]
          },
          {
            'categoryName': 'Savouries',
            'dishes': [
              'Panner pattice',
              'Veg Burger',
              'Pan Pizza Veg',
              'Veg pattice'
            ]
          },
          {
            'categoryName': 'Chocolate',
            'dishes': ['Just Temptations']
          },
          {
            'categoryName': 'Plum & Bar cake',
            'dishes': ['Fruit Bar cake']
          },
        ]
      },
      {
        'index': 1,
        'restaurantName': 'Swami Hotel',
        'foodCategory': 'Family Hotel',
        'restReview': 2,
        'restImage': 'assets/images/Restaurant2.png',
        'distanceFromLocation': 40,
        'restStatus': 'open',
        'menuCategories': [
          {
            'categoryName': 'Veg Starter',
            'dishes': [ 'Paneer pahadi kabab','Garlic chana','Masala papad', 'Manchurian']
          },
          {
            'categoryName': 'Tandoori',
            'dishes': ['Chicken Tandoori','Chicken Tangadi Kabab','Chicken Pahadi Kabab','Mutton Kadhai]
          },
          {
            'categoryName': 'INDIAN BREAD',
            'dishes': ['Aalu Paratha','Paneer Paratha','Nan', 'Butter Nan','Tandoori Roti','Chapati']
          },         
        ]
      },
      {
        'index': 2,
        'restaurantName': 'Diva Sagar',
        'foodCategory': 'Family restaurant',
        'restReview': 5,
        'restImage': 'assets/images/Restaurant3.png',
        'distanceFromLocation': 30,
        'restStatus': 'open',
      },
      {
        'index': 3,
        'restaurantName': 'Smart open pick cake shop',
        'foodCategory': 'Cake Shop',
        'restReview': 1,
        'restImage': 'assets/images/Restaurant4.png',
        'distanceFromLocation': 10,
        'restStatus': 'closed',
        'offer': 'Get 5% discount',
      },
    ]
  };
}

I wanted to add list to dishes. how can i do that ?

2 Answers 2

1

I have this json

{
"data": [
    {
        "id": 0,
        "code": "string",
        "title": "string",
        "description": "string",
        "orderDetails": [
            {
                "productId": 0,
                "product": {
                    "name": "string",
                    "code": "string",
                    "unit": {
                        "name": "string",
                        "id": 0
                    },
                    "brand": {
                        "name": "string",
                        "imagePath": "string",
                        "id": 0
                    },
                    "country": {
                        "name": "string",
                        "id": 0
                    },
                    "images": [
                        {
                            "path": "string",
                            "type": 1,
                            "id": 0
                        }
                    ],
                    "productInfos": [
                        {
                            "qty": 0,
                            "price": 0,
                            "sumSale": 0,
                            "warranty": true,
                            "score": 0
                        }
                    ],
                    "qtyCart": 0,
                    "oldQtyCart": 0,
                    "sumSale": 0,
                    "saleRoles": [
                        {
                            "groupId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                            "multipleQTY": 0,
                            "saleRoleType": {
                                "value": "string",
                                "id": 1
                            },
                            "id": 0
                        }
                    ],
                    "groupId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
                    "multipleQTY": 0,
                    "saleRuleType": "string",
                    "familtySearchedHighLight": true,
                    "joinSearchedHighLight": true,
                    "id": 0
                },
                "qty": 0,
                "price": 0,
                "oldQty": 0,
                "oldUnitPrice": 0,
                "unitPrice": 0,
                "finalPrice": 0,
                "sumPrice": 0
            }
        ],
        "orderStatusId": 1,
        "orderStatus": {
            "description": "string",
            "id": 1
        },
        "shippings": [
            {
                "shipperName": "string",
                "shipperHtmlData": "string",
                "driverName": "string",
                "driverHtmlData": "string",
                "car": "string",
                "carIdentity": "string",
                "driverPhone": "string",
                "shipperPhone": "string",
                "orderId": 0,
                "totalItems": 0,
                "shippingCost": 0,
                "increasedCost": 0,
                "increasedCostDescription": "string",
                "blNo": "string",
                "departureTime": "2021-05-08T07:34:22.288Z",
                "deliveredTime": "2021-05-08T07:34:22.288Z",
                "originCity": "string",
                "originProvince": "string",
                "originAddress": "string",
                "targetCity": "string",
                "targetProvince": "string",
                "targetAddress": "string",
                "documentAttach": "string",
                "inTownShipping": true,
                "id": 0
            }
        ],
        "profileId": 0,
        "paymentDocAuthority": "string",
        "referenceId": "string",
        "deliveryProvince": "string",
        "deliveryCity": "string",
        "deliveryAddress": "string",
        "createDm": "2021-05-08T07:34:22.288Z",
        "createDs": "string",
        "finalPrice": 0,
        "sumPrice": 0
    }
],
"isSuccess": true,
"statusCode": 200,
"message": "string"}

it is as complex as your json with https://javiercbk.github.io I create a class out of it which is very long so i won't post it but you can try it yourself if you create a class for it you can add delete and actually everything with it

there is something wrong with your json and I could not use it on that website please take a look at my json and correct your json

Sign up to request clarification or add additional context in comments.

Comments

0

I got what I have to do.

{
        'index': 3,
        'restaurantName': 'abc',
        'foodCategory': 'abc1',
        'restReview': 1,
        'restImage': 'assets/images/Restaurant.png',
        'distanceFromLocation': 10,
        'restStatus': 'closed',
        'offer': 'Get 5% discount',
        'menuCategories': [
          {
            'categoryName': 'XYZ',
            'dishes': [
              {
                'dishName': 'XYZ1',
                'price': 300,
              },
              {
                'dishName': 'XYZ2',
                'price': 50,
              },
              {
                'dishName': 'XYZ3',
                'price': 35,
              },
              {
                'dishName': 'XYZ4',
                'price': 50,
              },
            ]
          },
          {
            'categoryName': 'PQR',
            'dishes': [
              {
                'dishName': 'PQR1',
                'price': 5,
              },
              {
                'dishName': 'PQR2',
                'price': 50,
              },
              {
                'dishName': 'PQR3',
                'price': 35,
              },
              {
                'dishName': 'PQR4',
                'price': 50,
              },
            ]
          },
        ]
      },

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.