typeMismatch "Not an array"
I have a model where one of the properties is a dictionary like this:
struct MyModel: Codable {
let userIds: [String: Bool]
}
This works fine, it decodes and encodes just fine. However, I want to use the https://github.com/pointfreeco/swift-tagged to add type-safety to my models instead of using strings everywhere. That also means that I want to change the above model to something like this:
struct MyModel: Codable {
let userIds: [User.Id: Bool]
}
Even though that should work just fine with Codable, I am getting this error:
typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "matchedUserIds", intValue: nil)], debugDescription: "Not an array", underlyingError: nil))
Not sure why it's looking for an array?
Plus. Also ran into this problem. Do you find answer?
No :(
Also ran into this problem :( For me in the main struct i added a sub struct. Both are conforming to the Codable protocol.
struct MainStruct:Codable{ let name:String let someInfo: SubStruct }
Throws the following error:
typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "SomeValue", intValue: nil), CodingKeys(stringValue: "SomeOtherValue", intValue: nil)], debugDescription: "Not an array", underlyingError: nil))
"SomeValue" and "SomeOtherValue" are vars within the SubStruct
Okay Sorry :/ My fault. I typed FirebaseDecoder instead of FirestoreDecoder
It would be nice if there was a little note in the error message if that's feasible.
It may be better if FirebaseDecoder is renamed to something like RealtimeDBDecoder