From 0f60874210205be9492ae7a19401d7ec145f73ab Mon Sep 17 00:00:00 2001 From: Jan Supol Date: Mon, 8 Jun 2020 23:04:49 +0200 Subject: [PATCH] Added Documentation for JSON-B support Signed-off-by: Jan Supol --- docs/src/main/docbook/jersey.ent | 13 +++++- docs/src/main/docbook/media.xml | 80 +++++++++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 3 deletions(-) diff --git a/docs/src/main/docbook/jersey.ent b/docs/src/main/docbook/jersey.ent index 520c599e35..f7d8b3e559 100644 --- a/docs/src/main/docbook/jersey.ent +++ b/docs/src/main/docbook/jersey.ent @@ -54,8 +54,9 @@ - - + + + jersey-bean-validation" > jersey-declarative-linking" > @@ -67,6 +68,7 @@ jersey-media-json-jettison" > jersey-media-json-jackson" > jersey-media-json-jackson1" > +jersey-media-json-binding" > jersey-media-moxy" > jersey-media-multipart" > jersey-mvc" > @@ -103,6 +105,7 @@ Microprofile Config Specification"> Helidon"> SmallRye"> +Yasson"> Configuration"> @@ -597,6 +600,8 @@ SseEventSource"> InboundSseEvent"> +JsonbConfig"> + JERSEY-2838"> @@ -636,6 +641,7 @@ jersey-media-json-jettison" > jersey-media-json-jackson" > jersey-media-json-jackson1" > +jersey-media-json-binding" > jersey-media-moxy" > jersey-media-multipart" > jersey-rx-client" > @@ -903,6 +909,7 @@ JettisonConfig" > JettisonJaxbContext" > JsonProcessingFeature" > +JsonBindingFeature" > MoxyJsonConfig" > MoxyJsonFeature" > ObjectMapper" > @@ -1036,3 +1043,5 @@ TestContainerFactory"> LoopBackConnectorProvider"> ContainerRequestBuilder"> + +Jsonb"> \ No newline at end of file diff --git a/docs/src/main/docbook/media.xml b/docs/src/main/docbook/media.xml index bc79dab57b..03d1381106 100644 --- a/docs/src/main/docbook/media.xml +++ b/docs/src/main/docbook/media.xml @@ -22,6 +22,7 @@ Java API for JSON Processing (JSON-P)" > Jackson" > Jettison" > + Java API for JSON Binding (JSON-B)" > %ents; ]> @@ -64,6 +65,9 @@ &link.jettison; + + &link.json-b; + @@ -97,7 +101,7 @@ POJO support POJO support represents the easiest way to convert your Java Objects to JSON and back. - Media modules that support this approach are &link.moxy; and &link.jackson; + Media modules that support this approach are &link.moxy;, &link.jackson;, and &link.json-b;
@@ -1076,6 +1080,80 @@ public JaxbBean getSimpleJSONP() {
+
+ Java API for JSON Binding (JSON-B) + + + Jersey uses &yasson.link; for JSON Binding (JSR-367) implementation. + +
+ Dependency + + To use JSON-B as your JSON provider you need to add &lit.jersey-media-json-binding; module to your + &lit.pom.xml; file: + + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-binding</artifactId> + <version>&version;</version> +</dependency> + + If you're not using Maven make sure to have all needed dependencies + (see &jersey.media.json-binding.deps.link;) on the classpath. + +
+ +
+ Configure and register + + + As stated in JSON-Binding media module is one of the + modules where you don't need to explicitly register its + &lit.jaxrs.core.Feature;s (&lit.jersey.media.JsonBindingFeature;) in your client/server + &jaxrs.core.Configurable; as this feature is automatically discovered and registered when you add + &lit.jersey-media-json-binding; module to your classpath. + + + To use custom preconfigured JSON-B, it is simply possible to register + a &lit.jaxrs.ext.ContextResolver; for &lit.jsonb.Jsonb; in your &jaxrs.core.Configurable; + (client/server) and configure &jsonb.JsonbConfig;. + + + + <literal>ContextResolver<Jsonb></literal> + + @Provider +public class JsonbContextResolver implements ContextResolver<Jsonb> { + + @Override + public Jsonb getContext(Class>?< type) { + JsonbConfig config = new JsonbConfig(); + // configure JsonbConfig + ... + return JsonbBuilder.create(config); + } +} + + + <literal>Register the feature and ContextResolver<Jsonb></literal> + ClientBuilder.newClient(new ClientConfig() + // The line below that registers JSON-Binding feature can be + // omitted if FEATURE_AUTO_DISCOVERY_DISABLE is not disabled. + .register(JsonBindingFeature.class) + .register(JsonbContextResolver.class) +); + + + + Example + + You can take a look at a provided + JSON-B example.. + + +
+ +