-
Notifications
You must be signed in to change notification settings - Fork 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
Fully Support Null Fields when Using Custom ObjectSerializer #29238
Conversation
/azp run java - search - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
API change check API changes are not detected in this pull request. |
/azp run java - search - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
...-search-documents/src/main/java/com/azure/search/documents/implementation/DocumentsImpl.java
Show resolved
Hide resolved
boolean startsWithCurlyBrace = documentJson.startsWith("{"); | ||
boolean endsWithCurlyBrace = documentJson.endsWith("}"); |
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.
Is content expected to be trimmed? I.e. is \t\t{ ... }\n\n
possible ?
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.
It should be trimmed given that it's serialization of the object without passing through other calls.
Description
Fixes #28610
Resolves a gap in functionality where a custom
ObjectSerializer
would be used to convert a customer owned type into aMap<String, Object>
which would be serialized byJacksonAdapter
to be sent to the service. This didn't handle null key-value pairs properly asJacksonAdapter
is configured, and will continue to be configured, to ignore null values, but this defeated the purpose of the customObjectSerializer
to allow for custom handling to be applied to customer owned types.Now, if an
ObjectSerializer
is included in theSearchClient
it will be used to convert the document into a JSON string and be injected directly into the serialized JSON, giving full control of document serialization to a customer if they choose, or need, to use it. This should also add small performance improvement as before documents would be converted to JSON to be converted into aMap<String, Object>
and would then later be converted back to JSON when sending the final request. Customers not usingObjectSerializer
will continue to see the same runtime behaviors as before where null field values aren't included in the document sent to the service.All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines