Skip to main content

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

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

 


Back to the top