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

Provide a way to configure how byte[] is serialized #1869

Closed
chrischu opened this issue Oct 10, 2018 · 2 comments
Closed

Provide a way to configure how byte[] is serialized #1869

chrischu opened this issue Oct 10, 2018 · 2 comments

Comments

@chrischu
Copy link

It would be awesome if there was an easy way to configure how byte[] is serialized. As far as I know by default byte[] is serialized as a Base64-encoded string, however, we would prefer if the byte[] is serialized as JSON array instead. We know we can use a custom JsonConverter, but it seems odd that this (at least in our mind) very peculiar behavior cannot be configured in an easier way.

There are several reasons for this wish:

  • We like the symmetry with other array types
  • If we omit the type name when having a property with a declared type of IReadOnlyList<byte> and an actual type of byte[] it would still work, while it does not work when the byte[] is serialized as string, since the deserializer cannot infer that the string actually represents bytes.

Is there already an easy way to configure the byte[] serialization behavior we don't know of?

@JamesNK
Copy link
Owner

JamesNK commented Oct 14, 2018

JsonConverter is how you do this. Adding a setting to customize how every type is serialized isn't reasonable.

@JamesNK JamesNK closed this as completed Oct 14, 2018
@chrischu
Copy link
Author

Maybe not every type, but every type that is handled unexpectedly? There are settings for how DateTimes are serialized aren't there?

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