emfjson / emfjson-jackson

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

Incorrect serialization of map entries when key/value are references (not containments) #83

Closed ghillairet closed 7 years ago

ghillairet commented 8 years ago

Current serializer will save key/value of a map entry as containment even if the key or value is defined as a reference.

Sample map definition with references.

class TMapRef wraps Map.Entry {
    refers PrimaryObject key
    refers TargetObject value
}

will serialize as

{
    "eClass": "http://www.emfjson.org/jackson/model#//ETypes",
    "valuesWithRef": [
      {
        "key": {
          "eClass": "http://www.emfjson.org/jackson/model#//PrimaryObject",
          "name": "p1"
        },
        "value": {
          "eClass": "http://www.emfjson.org/jackson/model#//TargetObject",
          "singleAttribute": "t1"
        }
      }
    ]
  }

but should instead contain references, something like

{
    "eClass": "http://www.emfjson.org/jackson/model#//ETypes",
    "valuesWithRef": [
      {
        "key": {
          "$ref": "p1"
        },
        "value": {
          "$ref": "t1"
        }
      }
    ]
  }
tarelli commented 8 years ago

:+1:

ghillairet commented 7 years ago

This has been fixed in RC1