Skip to content

Skip cannot Encode optional dictionary #62

@rafaelnobrekz

Description

@rafaelnobrekz

Hello! When using JSONEncoder, dictionary types that are optional are not correctly encoded by Skip.

struct TestEntity2: Codable {
    let optionalDict: [String: String]?
    let nonOptionalDict: [String: String]
}

// This succeeds ✅
try! JSONEncoder().encode(TestEntity2(optionalDict: nil, nonOptionalDict: [:]))
// This fails ❌ data error skip.lib.ErrorException: java.lang.ClassCastException: skip.lib.Tuple2 cannot be cast to skip.lib.Encodable
try! JSONEncoder().encode(TestEntity2(optionalDict: ["1": "abc"], nonOptionalDict: ["1": "abc"]))

I'm currently working around by using a non optional dict and making it empty to represent nil.
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions