Skip to content

Add support for Java records and Optional serialization in the JSON plugin.#1792

Open
srilakshmikanthanp wants to merge 2 commits into
apache:mainfrom
srilakshmikanthanp:main
Open

Add support for Java records and Optional serialization in the JSON plugin.#1792
srilakshmikanthanp wants to merge 2 commits into
apache:mainfrom
srilakshmikanthanp:main

Conversation

@srilakshmikanthanp

Copy link
Copy Markdown

Summary

  • Java records are now serialized using RecordComponent metadata, as Introspector.getBeanInfo() does not expose record components through the traditional JavaBeans property model.
  • java.util.Optional now serializes as its contained value or null when empty. Optional.empty() is treated as null when excludeNullProperties is enabled, including for bean/record properties and map values.
  • @JSON and @JSONFieldBridge annotations can now be applied directly to record components.

I implemented these changes based on my understanding of the existing codebase and tried to keep the implementation minimal and consistent with the current design.

I'd appreciate a review of the implementation and approach. If you'd like any changes, please let me know and I'll update the PR.

@lukaszlenart

Copy link
Copy Markdown
Member

Please create a JIRA ticket first https://issues.apache.org/jira/projects/WW/

@srilakshmikanthanp

Copy link
Copy Markdown
Author

Thanks! I've requested an Apache JIRA account. Once it's approved, I'll create the JIRA issue and update this PR with the issue number.

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.

2 participants