|Single Ecore domain model, two conflicting serializations, now what? [message #1748290]
||Mon, 21 November 2016 20:23
| Daniel Ford
Registered: July 2009
Location: New York
I have an Ecore model that represents a particular domain model. I also have two different "standard" serializations of the model developed by others (i.e., I can't change them). One serialization is essentially JSON, while the other is a DSL.|
My problem is that they have different conflicting serializations of sets of key/value pairs that I'm having difficulty resolving. The issue is that a key may appear in multiple key/value pairs, and the two different serializations have different ways of representing that.
The first serialization definition is essentially JSON and uses a JSON array for multiple values:
e.g., "key" : [ 2, 3 ]
while, the second is a DSL that just repeats the key value:
Of course, the pairs can occur in any order, and be combined with other pairs with different keys and values.
I know how to handle/represent/parse the JSON case, but being able to do the same for the DSL given the same common underlying Ecore model is not clear to me.
In the first case (i.e., JSON), I can have something in the common Ecore model that would represent a mapping between the key and a list of its values. in the second case (DSL), I'm not sure how to recognize multiple uses of the same key, and then get the collection of its values into the same list in an instance of the Ecore model.
One approach I've wondered about is to use some kind of ability to be notified when the parser has recognized a collection of key/values, and have it call out to my custom code to do a bit of aggregation of the keys and their values in the AST under construction. Something similar would need to happen in the reverse for serialization to the DSL.
Powered by FUDForum
. Page generated in 0.03664 seconds