-
Notifications
You must be signed in to change notification settings - Fork 23
attribute serialization #58
Comments
Library version is 0.10.0 |
Attributes filtered in org.emfjson.jackson.streaming.StreamWriter.generate() on line 151, here calls org.emfjson.common.EObjects.isCandidate(): public static boolean isCandidate(EObject object, EAttribute attribute) {
return (object.eIsSet(attribute) || attribute.getEType() instanceof EEnum) &&
!attribute.isDerived() &&
!attribute.isTransient() &&
!attribute.isUnsettable();
} For some needed attributes object.eIsSet(attribute) is false or !attribute.isUnsettable() is false. Why this filter needs? |
Checking that isUnsettable in that method is a mistake, will be remove in next version, see #59 Map<String, Object> options = new HashMap<>();
options.put(EMFJs.OPTION_USE_ID, true);
resource.save(options); |
Yes, but it realy don't work until Resource implementation, that also implenets UuidResource interface, do not return true in UuidResource.useUUIDs(). I think it realy needed to use custom JsonResourceFactory with custom JsonResource that overrided useUUIDs(). For this aim need to set custom JsonResourceFactory to EObjectDeserializer and ResourceDeserializer. It works for me, if needed I can do a pull request. |
That's the correct behavior, the default id serializer will serialize the fragment of the object's URI only if the option USE_ID is true. For the fragment to be a UUID you need to have a Resource implementation that supports UUID generation (like XMIResource, JsonResource) and overwrite the method useUUIDs() to return true. Since 0.11 you can also use custom serializers for ids, see cdo sample. |
Yes, but what you think about custom JsonResourceFactory in EObjectDeserializer and ResourceDeserializer? |
What are you thinking about? Not sure I understand the need to use a ResourceFactory in those deserializers. |
How I can configure deserializer with custom JsonResource? |
For this purpose I realize ResourceFactory and expect my custom JsonResource, but I get a standart JsonResource |
What are you trying to achieve? If you want to use a custom resource implementation you need to specify it through the resourceSet. |
Yes, but your deserializer creates only yours JsonResource |
Are you referring to this https://github.com/ghillairet/emfjson/blob/master/emfjson-jackson/src/main/java/org/emfjson/jackson/databind/deser/ResourceDeserializer.java#L86 If so, you should use the object mapper context to tell which resource is the target, like here https://github.com/ghillairet/emfjson/blob/master/emfjson-jackson/src/main/java/org/emfjson/jackson/resource/JsonResource.java#L56 |
Hi,
I have a problen with json serialization of ecore model. I'm trying to create .uml and .json (with emfjson) files like this:
Created .uml is right:
But .json is not, there no attributes (in this case "name" attribute):
What happen? What I should do?
The text was updated successfully, but these errors were encountered: