Skip to content

JSONEncoder.encode(_:,key:) fails to compile with value argument cast to JSONEncodable #52

Description

@djdiaz

This fails to compile:

let val: JSONEncodable = SomeTypeThatImplementsJSONEncodable()
public func toJSON() throws -> AnyObject {
    return try JSONEncoder.create { encoder in
        try encoder.encode(val, key: "SomeKey")
    }
}

The error given is "Cannot invoke 'encode' with an argument list of type '(JSONEncodable, key: String)'." This seems to be because the following method on JSONEncoder is marked private:

private func encode(value: JSONEncodable, key: String) throws

Is there some reason this shouldn't be marked public?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions