fix: omit optional fields with default values from client JSON serialization#774
Open
jmesnil wants to merge 1 commit intoa2aproject:mainfrom
Open
fix: omit optional fields with default values from client JSON serialization#774jmesnil wants to merge 1 commit intoa2aproject:mainfrom
jmesnil wants to merge 1 commit intoa2aproject:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors JSON serialization in JSONRPCUtils.java by removing the alwaysPrintFieldsWithNoPresence() configuration, which results in more compact JSON output. Correspondingly, several test cases in JsonMessages.java were updated to remove empty metadata objects and default boolean fields. Feedback suggests optimizing performance by defining JsonFormat.Printer instances as static final constants to avoid redundant object creation during serialization.
…ization The JSON-RPC client serialization used alwaysPrintFieldsWithNoPresence() which caused proto3 implicit-presence fields (taskId, contextId, tenant, etc.) to be serialized as empty strings instead of being omitted. Removed alwaysPrintFieldsWithNoPresence() from JsonFormat.printer() in JSONRPCUtils.toJsonRPCRequest() (client requests only), aligning with the REST client transport which already omitted it. This fixes a2aproject#770
c5c4c3b to
47dc31b
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in 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.
The JSON-RPC client serialization used alwaysPrintFieldsWithNoPresence() which caused proto3 implicit-presence fields (taskId, contextId, tenant, etc.) to be serialized as empty strings instead of being omitted.
Removed alwaysPrintFieldsWithNoPresence() from JsonFormat.printer() in JSONRPCUtils.toJsonRPCRequest() (client requests only), aligning with the REST client transport which already omitted it.
This fixes #770