SwiftyLab / MetaCodable

Supercharge Swift's Codable implementations with macros meta-programming.

Home Page:https://swiftpackageindex.com/SwiftyLab/MetaCodable/main/documentation/metacodable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for different coding keys for encoding / decoding the same property

murad1981 opened this issue · comments

Is there a way to decode a model's property key with a name and encode it using a different name ?
for ex. if have the following model:

@Codable
struct UserInfo {
 
@CodedAt("emailAddress")
  var email: String 
}

when I fetch the model from the api it returns the email field using the key name: "emailAddress" in the incoming json, but when I post the same model to a different api I want to use the name: "email" instead of "emailAddress"