-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Support customized reading and writing of JSON values #31021
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
|
||
/// <inheritdoc /> | ||
public override byte[] FromJsonTyped(ref Utf8JsonReaderManager manager) | ||
=> manager.CurrentReader.GetBytesFromBase64(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we decide to also accept number arrays?
/// <inheritdoc /> | ||
public virtual JsonValueReaderWriter? FindReaderWriter(Type type) | ||
{ | ||
if (type == typeof(int)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@roji I don't think this will appear on a hot path, but can you think of a faster way of implementing this?
Part of #30604 |
Part of #30730 - Type mappings now have a `JsonValueReaderWriter` that handles reading and writing JSON for the type. - This can be overridden by a `JsonValueReaderWriter` on a property, for example, to allow GeoJson to be written instead of WKT. - These are typically singleton instances, and can be optimized out for well-known cases. - If the type mapping has a converter, then the converter must be applied to the value before being written to JSON, and the converter must be applied after reading the JSON value. - If the property itself has a `JsonValueReaderWriter`, then the unconverted property value is passed to this reader/writer.
e31db4d
to
3c27726
Compare
Part of #30730
JsonValueReaderWriter
that handles reading and writing JSON for the type.JsonValueReaderWriter
on a property, for example, to allow GeoJson to be written instead of WKT.JsonValueReaderWriter
, then the unconverted property value is passed to this reader/writer.