So I’m working on a personal project to analyze data from a json on my apple watch and im stuck on serializing the json. In some parts of the json, some keys are present and in others there’s keys missing. I’ve created a struct (below) to organize the information correctly but I want to be able to check that they are all there or add a key with a default value if it is missing.
public struct dataParameters: Encodable, Decodable{
let key1: String
let key2: String
let key3: Int }
“dataParameters": [{“key1": "0", “key2": "0”}]
How can I check the keys present and then handle any missing one?