emfjson / emfjson-jackson

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

When a map is used JSON serialization is wrong #74

Closed tarelli closed 8 years ago

tarelli commented 8 years ago

We have an ecore with one reference named "initialValue" that is a map, here is a screenshot of the ecore: screen shot 2015-12-09 at 15 07 52

When such reference is serialized the following JSON is produced:

                "id": "g",
                "name": "g",
                "types": [{
                    "$ref": "//@libraries.1/@types.2"
                }],
                "initialValues": {: {

The problem is the double :{ :{ the second colon is unexpected. Uncaught SyntaxError: Unexpected token :

tarelli commented 8 years ago

@ghillairet do you have a tentative due date for 0.14? Trying to decide the best course of action around this, thanks!

ghillairet commented 8 years ago

The fix for this one will be in maven snapshot repository today or tomorrow.

For maps that don't have keys of type string the serialization will look like that

{
  "eClass" : "http://www.emfjson.org/jackson/model#//ETypes",
  "values" : [ {
    "key" : {
      "eClass" : "http://www.emfjson.org/jackson/model#//Type",
      "name" : "t1"
    },
    "value" : {
      "eClass" : "http://www.emfjson.org/jackson/model#//Value",
      "value" : 1
    }
  }, {
    "key" : {
      "eClass" : "http://www.emfjson.org/jackson/model#//Type",
      "name" : "t2"
    },
    "value" : {
      "eClass" : "http://www.emfjson.org/jackson/model#//Value",
      "value" : 2
    }
  } ]
}

A map with keys being string is serialized like that

{
  "eClass" : "http://www.emfjson.org/jackson/model#//ETypes",
  "values" : {
     "t1": 1,
     "t2": 2 
  }
}
tarelli commented 8 years ago

@ghillairet great, thanks Guillaume!

tarelli commented 8 years ago

@ghillairet hi Guillaume, any update on release 0.1.4? Thanks!

ghillairet commented 8 years ago

I won't have time before next week, due to the move to the organization I have to re-setup the build for the eclipse update site.

tarelli commented 8 years ago

@ghillairet let me know if there's anything I can do to help :)

ghillairet commented 8 years ago

0.14 has been released (https://github.com/emfjson/emfjson-jackson/releases/tag/0.14.0) and includes fix for this issue.

tarelli commented 8 years ago

@ghillairet if the key is not contained in the map should there be a reference instead of the whole object?

ghillairet commented 8 years ago

Yes you're right, see https://github.com/emfjson/emfjson-jackson/issues/83