Errors on app and simulator not starting, Xcode 12.2

102 Views Asked by At

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

1

There are 1 best solutions below

0
On BEST ANSWER

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")