Skip to content

Commit bd9e757

Browse files
committed
Improve javadoc
1 parent 56b96c5 commit bd9e757

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

jsonb-jackson/src/main/java/io/avaje/jsonb/jackson/JacksonAdapter.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,42 @@
1414
import java.io.*;
1515

1616
/**
17-
* Jackson Core implementation of IOAdapter.
17+
* Jackson Core implementation of JsonStreamAdapter.
18+
* <p>
19+
* This uses the JsonParser and JsonGenerator of Jackson core to do the underlying parsing and
20+
* generation.
21+
*
22+
* <h3>Explicitly initialise</h3>
23+
* <p>
24+
* We can use it explicitly using code like:
25+
*
26+
* <pre>{@code
27+
*
28+
* JsonFactory customFactory = ...;
29+
*
30+
* var jacksonAdapter = JacksonAdapter.newBuilder()
31+
* .serializeNulls(true)
32+
* .jsonFactory(customFactory)
33+
* .build();
34+
*
35+
* Jsonb jsonb = Jsonb.newBuilder()
36+
* .adapter(jacksonAdapter)
37+
* .build();
38+
*
39+
* }</pre>
40+
*
41+
* <h3>Service loading initialise</h3>
42+
* <p>
43+
* Including the <code>io.avaje:avaje-jsonb-jackson</em> dependency in the classpath means that this
44+
* JacksonAdapter will be automatically used via service loading.
45+
* <p>
46+
* In this automatic service loading case the defaults are:
47+
* <ul>
48+
* <li>new JsonFactory()</li>
49+
* <li>serializeNulls false</li>
50+
* <li>serializeEmpty false</li>
51+
* <li>failOnUnknown false</li>
52+
* </ul>
1853
*/
1954
public class JacksonAdapter implements JsonStreamAdapter {
2055

@@ -112,6 +147,10 @@ public JacksonAdapter(boolean serializeNulls, boolean serializeEmpty, boolean fa
112147
* .jsonFactory(customFactory)
113148
* .build();
114149
*
150+
* Jsonb jsonb = Jsonb.newBuilder()
151+
* .adapter(jacksonAdapter)
152+
* .build();
153+
*
115154
* }</pre>
116155
*/
117156
public static Builder newBuilder() {

jsonb/src/main/java/io/avaje/jsonb/Jsonb.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,27 @@
3333
* .build();
3434
* }</pre>
3535
*
36+
* <h4>Initialise using Jackson core with configuration</h3>
37+
* <p>
38+
* We need to include the dependency <code>io.avaje:avaje-jsonb-jackson</code> to do this.
39+
* This will use Jackson core JsonParser and JsonGenerator to do the underlying parsing and generation.
40+
* </p>
41+
* <pre>{@code
42+
*
43+
* // create the Jackson JsonFactory
44+
* JsonFactory customFactory = ...;
45+
*
46+
* var jacksonAdapter = JacksonAdapter.newBuilder()
47+
* .serializeNulls(true)
48+
* .jsonFactory(customFactory)
49+
* .build();
50+
*
51+
* Jsonb jsonb = Jsonb.newBuilder()
52+
* .adapter(jacksonAdapter)
53+
* .build();
54+
*
55+
* }</pre>
56+
*
3657
* <h4>fromJson</h4>
3758
* <p>
3859
* Read json content from: String, byte[], Reader, InputStream, JsonReader

0 commit comments

Comments
 (0)