Following the apple developer tutorial on swiftui, https://developer.apple.com/tutorials/swiftui/
I would like to modify it a little bit to include some more fields in the object Landmark:
For example:
struct Landmark: Hashable, Codable, Identifiable {
var id: Int
var name: String
var park: String
var state: String
var description: String
var isFavorite: Bool
var isFeatured: Bool
var comment: String // example, added this field
}
Yet, for this field, I would like to use it for user to input comment. The String would not be available in the .json file, and hence cannot fill in this information at the stage of "load"-ing the json data.
I found that this will cause error and app crash when this field is not available in the JSON file. How can I resolve this issue? Is that a must that all the fields in the object must appear in the JSON file?