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

[Question] Mixing custom serializer with one from the builder #549

Open
bootzin opened this issue Dec 6, 2020 · 1 comment
Open

[Question] Mixing custom serializer with one from the builder #549

bootzin opened this issue Dec 6, 2020 · 1 comment

Comments

@bootzin
Copy link

bootzin commented Dec 6, 2020

Is it possible to combine a custom serializer with one from the builder?

For instance: I have a class in my code which I want to do some manual serialization. So I go about adding mappings and sequences, but then there's a subclass in it which I don't want to serialize manually, and would rather call serializer.Serialize(currentEmitter, subclass)

The problem is, when I do this, I end up with an exception since the serializer calls DocumentStart and StreamStart, but the emitter is expecting a Scalar, Sequence, Mapping or Alias

So, is there a way to call the serializer so that it adds to an already existing emitter?

@aaubry
Copy link
Owner

aaubry commented Jan 18, 2021

Sorry for the late answer. You can use the BuildValueSerializer method of the builder to get an IValueSerializer instance, which only emits the "content" of the focument, not the DocumentStart / StreamStart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants