New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTL-890: Serialization with json #888

Closed
GeertvanHorrik opened this Issue Jun 6, 2016 · 17 comments

Comments

Projects
None yet
2 participants
@GeertvanHorrik
Member

GeertvanHorrik commented Jun 6, 2016

Jira issue originally created by user mattias:

Hi.

I try to switch my serialization from xml to json. I installed the package Catel.Serialization.Json.

But how to to change the SerializationMode. Its only possible to set SerializationMode.XML or SerializationMode.Binary.

I don't find any helpt so serialize with json in catel.

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Jun 6, 2016

Member

Comment created by @GeertvanHorrik:

The SerializationMode inside the model is probably a design mistake in the beginnings of Catel. We should have just used a service in the service locator and use the registered type.

To serialize using json, resolve the service from the service locator and specify the model to be serialized as json.

Member

GeertvanHorrik commented Jun 6, 2016

Comment created by @GeertvanHorrik:

The SerializationMode inside the model is probably a design mistake in the beginnings of Catel. We should have just used a service in the service locator and use the registered type.

To serialize using json, resolve the service from the service locator and specify the model to be serialized as json.

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Jun 6, 2016

Member

Comment created by mattias:

Ok. At the moment I derive my model to serialize from SavableModelBase. And call the save method with the serializationmode.xml.

No I have to do what,

Resolve which service: JsonSerializer?
And how to "specify the model to be serialized as json"?

Member

GeertvanHorrik commented Jun 6, 2016

Comment created by mattias:

Ok. At the moment I derive my model to serialize from SavableModelBase. And call the save method with the serializationmode.xml.

No I have to do what,

Resolve which service: JsonSerializer?
And how to "specify the model to be serialized as json"?

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Jun 7, 2016

Member

Comment created by mattias:

Hi again.
I tested the json serilization now with a simple class.

I resolve JsonSerializer. (I do not specify the model model, because I don't know how, just derive from SavableModelBase.)

So it works. But in the file everything is in one line.

Member

GeertvanHorrik commented Jun 7, 2016

Comment created by mattias:

Hi again.
I tested the json serilization now with a simple class.

I resolve JsonSerializer. (I do not specify the model model, because I don't know how, just derive from SavableModelBase.)

So it works. But in the file everything is in one line.

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Jun 7, 2016

Member

Comment created by mattias:

Sorry one more question. I don't know if i have to ask here or in stackoverflow.

I have to serialize a complex member as string. So I override the SerializeMember Method from SerializerModifierBase. This works.
But in the method DeserializeMember i do not get this membervalue.

In xml it is set as type="System.String". but not in json so its not been deserialized.

Member

GeertvanHorrik commented Jun 7, 2016

Comment created by mattias:

Sorry one more question. I don't know if i have to ask here or in stackoverflow.

I have to serialize a complex member as string. So I override the SerializeMember Method from SerializerModifierBase. This works.
But in the method DeserializeMember i do not get this membervalue.

In xml it is set as type="System.String". but not in json so its not been deserialized.

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Jun 24, 2016

Member

Comment created by @GeertvanHorrik:

Please create a repro, I don't understand your question.

Member

GeertvanHorrik commented Jun 24, 2016

Comment created by @GeertvanHorrik:

Please create a repro, I don't understand your question.

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Jun 27, 2016

Member

Comment created by mattias:

Ok. Added a simple repro. I try to deserialize the property "SomeComplexInformation". Take a look at method DeserializeMember() in class SomeModelSerializerModifier in file SomeModel.cs

Member

GeertvanHorrik commented Jun 27, 2016

Comment created by mattias:

Ok. Added a simple repro. I try to deserialize the property "SomeComplexInformation". Take a look at method DeserializeMember() in class SomeModelSerializerModifier in file SomeModel.cs

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Feb 16, 2017

Member

Comment created by mattias:

Hi. Do you understand my question in the meantime.

I just wa't to serialize and deserialize a complex to and from a string.
So only serialize the name and on deserialize get an existing object from this name.

Member

GeertvanHorrik commented Feb 16, 2017

Comment created by mattias:

Hi. Do you understand my question in the meantime.

I just wa't to serialize and deserialize a complex to and from a string.
So only serialize the name and on deserialize get an existing object from this name.

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Mar 17, 2017

Member

Comment created by @GeertvanHorrik:

I can repro, will investigate what's going on.

Member

GeertvanHorrik commented Mar 17, 2017

Comment created by @GeertvanHorrik:

I can repro, will investigate what's going on.

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Mar 17, 2017

Member

Comment created by @GeertvanHorrik:

The Json serializer cannot deserialize the string into the right type, hence it's failing. We should have some sort of fallback mechanism (but we need to be careful about the types so we don't provide the wrong types).

Member

GeertvanHorrik commented Mar 17, 2017

Comment created by @GeertvanHorrik:

The Json serializer cannot deserialize the string into the right type, hence it's failing. We should have some sort of fallback mechanism (but we need to be careful about the types so we don't provide the wrong types).

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Mar 17, 2017

Member

Comment created by mattias:

I think the best is to do this with a attribute. IsCustomDeserializedAttribute for example

Member

GeertvanHorrik commented Mar 17, 2017

Comment created by mattias:

I think the best is to do this with a attribute. IsCustomDeserializedAttribute for example

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Mar 21, 2017

Member

Comment created by @GeertvanHorrik:

Not sure about the attributes, but I do agree we could expose this via the modifier (attributes "pollute" the model, where the serializer modifier is a custom self-contained logic part).

Member

GeertvanHorrik commented Mar 21, 2017

Comment created by @GeertvanHorrik:

Not sure about the attributes, but I do agree we could expose this via the modifier (attributes "pollute" the model, where the serializer modifier is a custom self-contained logic part).

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Mar 21, 2017

Member

Comment created by mattias:

Yes that's correct attributes pollute the model.

But:
[ExcludeFromSerialization]
[IncludeInSerialization]
[SerializeAsCollectionAttribute]

and so one are still there.

So I think we should have both attribute and serializer modifier. So its equal to the other features.

Member

GeertvanHorrik commented Mar 21, 2017

Comment created by mattias:

Yes that's correct attributes pollute the model.

But:
[ExcludeFromSerialization]
[IncludeInSerialization]
[SerializeAsCollectionAttribute]

and so one are still there.

So I think we should have both attribute and serializer modifier. So its equal to the other features.

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Mar 21, 2017

Member

Comment created by @GeertvanHorrik:

Ok, sounds fair. I'll look into this once I've reviewed your PR.

Member

GeertvanHorrik commented Mar 21, 2017

Comment created by @GeertvanHorrik:

Ok, sounds fair. I'll look into this once I've reviewed your PR.

@GeertvanHorrik GeertvanHorrik self-assigned this Apr 12, 2017

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Jun 28, 2017

Member

@MattiasEppler is this one still relevant?

Member

GeertvanHorrik commented Jun 28, 2017

@MattiasEppler is this one still relevant?

@GeertvanHorrik GeertvanHorrik added this to the 5.2.0 milestone Jun 28, 2017

@MattiasEppler

This comment has been minimized.

Show comment
Hide comment
@MattiasEppler

MattiasEppler Jun 28, 2017

Contributor

Yes it is.

Contributor

MattiasEppler commented Jun 28, 2017

Yes it is.

@GeertvanHorrik GeertvanHorrik modified the milestones: 6.0.0, 5.2.0 Sep 12, 2017

@GeertvanHorrik GeertvanHorrik modified the milestones: Up for grabs, 6.0.0 Sep 12, 2017

@GeertvanHorrik

This comment has been minimized.

Show comment
Hide comment
@GeertvanHorrik

GeertvanHorrik Jan 25, 2018

Member

@MattiasEppler we are trying to figure out whether we need to make changes to this. Can you refresh our minds a bit and explain what changes need to be done? Thanks!

Member

GeertvanHorrik commented Jan 25, 2018

@MattiasEppler we are trying to figure out whether we need to make changes to this. Can you refresh our minds a bit and explain what changes need to be done? Thanks!

@stale

This comment has been minimized.

Show comment
Hide comment
@stale

stale bot Apr 29, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale bot commented Apr 29, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 29, 2018

@stale stale bot closed this May 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment