j2labs/dictshield — Issue #40: Ability to manually override field names
Author: alexanderdean
Created: 2011-11-30 19:04:00+00:00
State: open

At the moment there is no way to unmarshal the following JSON using DictShield:

{
"code" : "GBP",
"self" : "http://localhost:8080/currencies/GBP" # Replacing with "link": works fine
}

... because the `self` key can't be defined as a field in a `Document` subclass. And similarly it's hard to work with the following:

{
"customer" : "Bob",
"email" : "bob@test.com",
"link" : {
"rel" : "self",
"href" : "http://localhost:8080/customer/2",
"type" : "text/xml"
},
"link" : {
"rel" : "next",
"href" : "http://localhost:8080/customer/3",
"type" : "text/xml"
},
"link" : {
"rel" : "prev",
"href" : "http://localhost:8080/customer/1",
"type" : "text/xml"
},
}

... because there are three elements with the same name.

It would be nice to have some sort of Jackson `@JsonProperty`-style naming override, like this:

self_link = StringField(property_name="self", required=True)

self_atom = EmbeddedDocumentField(AtomLink, property_name="link")
next_atom = EmbeddedDocumentField(AtomLink, property_name="link")
prev_atom = EmbeddedDocumentField(AtomLink, property_name="link")