Skip to content
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

How to make sure ITrackable properties are serialized properly #13

Closed
omatrot opened this issue Sep 12, 2019 · 1 comment

Comments

@omatrot
Copy link

commented Sep 12, 2019

I'm using dcerialize to deal with objet graphs coming and going through an ASP.NET Core Web API.

Dcerialize morks by using TypeScript decorators on properties.
Unannotated properties are not serialized or deserialized, they are totally ignored.

This is problematic when a modified graph must be sent back to the server beacuse those properties are not serializer aware, given the fact that they comes from this library.

How can I solve this problem?

@omatrot

This comment has been minimized.

Copy link
Author

commented Sep 12, 2019

I solved the problem by using the onSerialized event to do it by hand:

  static onSerialized(json: IJsonObject, instance: Vehicule) {
    // Add ITrackable properties that cannot be decorated
    json["trackingState"] = instance.trackingState;
    json["modifiedProperties"] = SerializeSet<String>(
      Array.from(instance.modifiedProperties.values()),
      () => String
    );
  }
@omatrot omatrot closed this Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.