Skip to content

RFC: Make Swift.Decodable conform to Argo.Decodable in Swift 4.1 #481

Description

@mdiep

I just had this idea, so it's possible it may not work, but…

The automatic synthesis of Swift.Decodable conformance is great… when you can use it. But IMO writing a custom decoder is much easier, flexible, and understandable with Argo.

So… what if Swift.Decodable conformed to Argo.Decodable with a default implementation?

  1. Write ArgoDecoder, which is a Swift.Decoder that decodes from a JSON (or whatever the new type is)
  2. Make Swift.Decodable conform to Argo.Decodable and add a default decode function that uses an ArgoDecoder

Then you'd be able to use any Swift.Decodable type natively with Argo. For any type that maps onto the JSON well, throw on Swift.Decodable and use the synthesized decoder. For anything else, use Argo—even if that type's properties use a synthesized decoder.

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