GillianPerard/typescript-json-serializer

[FEAT]: Could it be easier to use?

SF-Simon opened this issue · 3 comments

Description

Hello, I'm a multi-directional developer and I'm very grateful for this project because it makes my JSON scheme easier.
I only read the usage in the documentation so far, I don't know if there are some usages or limitations that I haven't found, so I express my thoughts, on the one hand, I can learn more, on the other hand, I can provide some development routes .

ps: These ideas come more from the Swift development language.

Proposed solution

  1. Is it possible to provide ignore-decoration attributes?
    In most cases, when we serialize and deserialize, we are based on the default class and its properties. So is it possible to ignore decorated properties and only add decorations to special properties? Such as @JsonObject(), @JsonProperty().

  2. Can there be singleton objects or static methods?
    Every time you use it, you need to create a new JsonSerializer object, but it is obviously more convenient to have a default setting or a static method that can contain configuration parameters.
    For example JsonSerializer.deserialize(json[, Organization]);

  3. Can there be more study cases?
    We have a lot of doubts and can only learn an initial way from the README, but we feel that there are still a lot of puzzles.
    For example, we are very confused about how to deal with the deserialization failure.

yet another decorator hell

Hi, thank you for posting here.

  1. I don't clearly understand this point. If you propose to not use @JsonProperty() and the class has as default behavior to retrieve all porperties as json one and just add a decoator to ignore some of them; I can't because I need this decorator to use reflection on it.
  2. I could create static functions to avoid creating an instance of the JsonSerializer, I need to try something because I don't want to create another breaking change for the moment.
  3. There are lot of examples cover major cases; you could inspect the examples folder. Regarding the failure behavior, it could happen in many ways but if the case is managed (due to nullishPolicy or additionalPropertiesPolicy) the code will launch the errorCallback function, by default it will log the error (another one is provided: throwError) but you can provide your own.
stale commented

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.