-1

I have a question. My page is giving me an error. It says:

Fatal error: Couldn't parse Rest.json as Array<Restaurant>:
dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." UserInfo={NSDebugDescription=Garbage at end.}))): file SaiMirrasKitchen/ModelData.swift, line 30

And what value to put to fix the simulator in the RestaurantRow.swift file, line 21? Thanks, Harri

Github Respoitory

Asperi
  • 228,894
  • 20
  • 464
  • 690
  • 3
    Hey Harry welcome to stackoverflow. Please create a [minimal, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – itaishz Dec 23 '20 at 20:44
  • 1
    Try checking for errors in your JSON with a tool like [this](https://jsonlint.com/) – aheze Dec 23 '20 at 20:49

1 Answers1

1

The json string is not valid , for your example it should be :

{"restaurants": [
    {
        "id":1001,
        "name":"Chapathi",
        "imageName":"Chapathi",
        "description":"Chapathi is a type of roti bread that is served all around the world.It is made of of wheat flour, oil, and water. Rolled and placed on a tawa.",
       "category":"Tiffin"
    },
    {
        "id":1002,
        "name":"Chapathi",
        "imageName":"Chapathi",
        "description":"Chapathi is a type of roti bread that is served all around the world.It is made of of wheat flour, oil, and water. Rolled and placed on a tawa.",
       "category":"Tiffin"
    }
  ]
}

and

let restaurants:Restaurants = load("Rest.json")
Ouail Bellal
  • 1,554
  • 13
  • 27