Skip to content

Consider runtime-specified value "template" value for missing fields (or patching) #2000

@kperryua

Description

@kperryua

Based on forum discussions here, consider capabilities like this:

struct BlogPost {
    var required: Int
    var items: [String] = []
}

// { "required" : 1 }
decode(template: BlogPost(required: 0), from: data)
// -> BlogPost(required: 1, items: [])

// { "required" : 1 }
decode(template: BlogPost(required: 0, items: ["world"]), from: data)
// -> BlogPost(required: 1, items: ["world"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestnew-codableRelated to new Swift (de)serialization APIs

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions