Skip to content

feat: add DataPart.fromJson() factory method for raw JSON strings#778

Open
jmesnil wants to merge 1 commit intoa2aproject:mainfrom
jmesnil:753_raw_json_string
Open

feat: add DataPart.fromJson() factory method for raw JSON strings#778
jmesnil wants to merge 1 commit intoa2aproject:mainfrom
jmesnil:753_raw_json_string

Conversation

@jmesnil
Copy link
Copy Markdown
Collaborator

@jmesnil jmesnil commented Mar 31, 2026

Allow developers to create a DataPart directly from a JSON string without manually deserializing it into Java objects first.

This fixes #753

Allow developers to create a DataPart directly from a JSON string
without manually deserializing it into Java objects first.

This fixes a2aproject#753

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces fromJson factory methods to the DataPart class, enabling the creation of instances from JSON strings using Gson. It also adds a comprehensive test suite in DataPartTest.java. A review comment identifies a potential Denial of Service vulnerability due to the lack of input size limits and suggests an explicit check for the JSON 'null' literal to ensure the implementation matches the provided Javadoc.

@ehsavoie
Copy link
Copy Markdown
Collaborator

@jmesnil Should it also provides OffsetDateTimeTypeAdapter ?

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

Successfully merging this pull request may close these issues.

[Feat]: I want to pass a JSON string to DataPart

2 participants