Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [che-dev] Custom JSON field names for DTOs

Hi,

Sounds OK for us.

Thanks

Gennady Azarenkov - CTO @ codenvy.com


On Wed, Jun 10, 2015 at 1:30 PM, Sharafy, Tareq <tareq.sharafy@xxxxxxx> wrote:

Hi,

We are developing some Che extensions that should consume externally defined/provided JSONs. The problem is that some of these JSONs have property names that are not valid java identifiers, making reliance on the method names of DTO interfaces insufficient. Specifically speaking, we need a way to enrich the DTO generator with custom JSON field names.

My proposed solution is to introduce a new annotation, @JsonFieldName("my-custom-name") at method level:
@DTO
interface MyType {
  @JsonFieldName("my-property")
  String getMyProperty();
  // .. setMyPropety, withMyProperty
}

So that the DTO generator emits code that serializes/deserializes the JSON accordingly, for example:
{ "my-property": "abc" }

Do you agree on this solution? Please provide any insights or suggestions.
If the solution is acceptable, please review my relevant pull request
www.github.com/codenvy/che-core/pull/111

thank you
Tareq Sharafy
Cloud Development Experience | SAP Labs Israel | 15 Hatidhar st, Raanana 43665, Israel
T +972-(0)7-4732-1647 | F +972-(0)9-777-5618

 


_______________________________________________
che-dev mailing list
che-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/che-dev



Back to the top