-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Add Jsonb support #9648
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
Add Jsonb support #9648
Conversation
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.
Wow, thanks for the pr @eddumelendez! Looks good and quite complete. I've made some comments.
In particular, I am not sure that the conditions part is mature. If you want us to brainstorm on this let me know!
@@ -572,12 +572,16 @@ | |||
}, | |||
{ | |||
"name": "spring.http.converters.preferred-json-mapper", | |||
"defaultValue" : "jackson", |
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.
This area is the hints
section, we can't see the default value there.
spring-boot-autoconfigure/pom.xml
Outdated
@@ -724,6 +734,12 @@ | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.eclipse</groupId> | |||
<artifactId>yasson</artifactId> | |||
<version>${javax-jsonb.version}</version> |
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.
That version shouldn't be there.
@@ -41,7 +43,7 @@ | |||
|
|||
@Configuration | |||
@ConditionalOnBean(Gson.class) | |||
@Conditional(PreferGsonOrMissingJacksonCondition.class) | |||
@Conditional(PreferGsonOrMissingJacksonAndJsonbCondition.class) |
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.
What is the rationale behind this? Gson
is to be used if both Jackson and JSonB are missing? With three choices, the combinations are becoming increasingly complex so I wonder if we shouldn't revisit this differently.
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.
regarding to the conditional thing. Should I rewrite conditions with an SpringBootCondition
implementation? Just to make sure, I would like to know that the current conditions are ok.
static class JacksonMissing { | ||
|
||
} | ||
|
||
@ConditionalOnProperty(name = HttpMessageConvertersAutoConfiguration.PREFERRED_MAPPER_PROPERTY, havingValue = "jsonb") |
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.
That particular one looks like a smell to me. What were you trying to express?
|
||
} | ||
|
||
private static class JacksonAndGsonMissing extends NoneNestedConditions { |
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.
Ditto. We should probably have a specific condition implementation for this
@@ -209,6 +219,12 @@ | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.eclipse</groupId> | |||
<artifactId>yasson</artifactId> | |||
<version>${javax-jsonb.version}</version> |
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.
Ditto. This version shouldn't be there.
spring-boot-test/pom.xml
Outdated
@@ -138,6 +148,12 @@ | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.eclipse</groupId> | |||
<artifactId>yasson</artifactId> | |||
<version>${javax-jsonb.version}</version> |
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.
Ditto for the version.
Note that Yasson itself is not a complete provider: that is, "org.eclipse:yasson:1.0" requires a manual extra declaration of "org.glassfish:javax.json:1.1" as the underlying JSON Processing provider. That's probably because Yasson is meant to be added to a Java EE server setup which comes with a JSON Processing provider out of the box. By contrast, Apache Johnzon's "org.apache.johnzon:johnzon-jsonb:1.1.1" is complete on its own, which is why we are using it for our JSON Binding API tests in the Spring Framework test suite. I have no experience with it otherwise though, so I can't make any judgement about its production capabilities or its benefits over Yasson in general. |
Thanks for feedback @snicoll and @jhoeller . I am working in small changes and I'll be back to discuss about condition topic. I just add
|
In regards to the previous comment, issue JOHNZON-132 was created and fix has been applied and it is scheduled for |
Spring Framework 5 will support Jsonb as a HttpMessageConverter, this commit adds auto-configuration support. Also, support for Jsonb in the @jsontest has been added. This implementation is running against Yasson (RI for Jsonb).
@@ -123,6 +126,7 @@ org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\ | |||
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\ | |||
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration,\ | |||
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\ | |||
org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration.\ |
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.
😬
* pr/9648: Polish "Add Jsonb support" Add Jsonb support
Thanks @eddumelendez! Merged with some polish in 8d63b74 |
Spring Framework 5 will support Jsonb as a HttpMessageConverter, this
commit adds auto-configuration support. Also, support for Jsonb in the
@jsontest has been added.
This implementation is running against Yasson (RI for Jsonb).