-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support customized reading and writing of JSON values #31021
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
AndriySvyryd
reviewed
Jun 5, 2023
AndriySvyryd
reviewed
Jun 6, 2023
|
||
/// <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?
AndriySvyryd
reviewed
Jun 6, 2023
/// <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?
AndriySvyryd
reviewed
Jun 6, 2023
AndriySvyryd
approved these changes
Jun 8, 2023
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
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.