tristanhimmelman / ObjectMapper

Simple JSON Object mapping written in Swift
MIT License
9.13k stars 1.03k forks source link

Support Multi-Keys #1129

Open tospery opened 2 years ago

tospery commented 2 years ago

Different JSON use different keys to identify the values that mean same thing. Likes, First JSON:

{
    "code" : 200,
    "message" : "success"
}

Second JSON:

{
    "code" : 200,
    "msg" : "success"
}

For the 'success' value, you can access the multi-keys object as follows:

func mapping(map: Map) {
    identifier <- map["message|msg", nested: false, delimiter: "|"]
}