emfjson / emfjson-jackson

JSON Binding for Eclipse Modeling Framework
https://emfjson.github.io
Other
80 stars 23 forks source link

Support for jackson like annotations #79

Closed ghillairet closed 6 years ago

ghillairet commented 8 years ago

Investigate addition of annotations, like in jackson.

Annotations could be defined in the textual format xcore like below, and also in the standard XMI format.

annotation "JsonProperty" as JsonProperty

class User {
    @JsonProperty(value = "user_name")
    String name
}

We should list in this issue the relevant annotations that could be supported.

ghillairet commented 7 years ago

JsonProperty annotation does now also work on methods since 1.0.0-rc.1

class TestB {

    @JsonProperty( value = "my_value" )
    String value

    @JsonProperty
    op String hello() {
        "World"
    }
}

will return

{
  "eClass": "http://www.emfjson.org/jackson/annotations#//TestB",
  "hello": "World"
}
kchobantonov commented 7 years ago

Should we assume that this option can be turned on and off per mapper ?

ghillairet commented 7 years ago

That is not at the moment something that can be turn off, if annotations are present in the ecore model, then the mapper will consider them.