@@ -89,7 +89,7 @@ static Builder newBuilder() {
89
89
/**
90
90
* Return json content for the given object.
91
91
* <p>
92
- * This is a convenience method for using {@code jsonb.type(Object.class).toJson(any) }
92
+ * This is a convenience method for {@code jsonb.type(Object.class).toJson(any) }
93
93
*
94
94
* @param any The object to return as json string
95
95
* @return Return json content for the given object.
@@ -99,28 +99,61 @@ static Builder newBuilder() {
99
99
/**
100
100
* Return json content in pretty format for the given object.
101
101
* <p>
102
- * This is a convenience method for using {@code jsonb.type(Object.class).toJsonPretty(any) }
102
+ * This is a convenience method for {@code jsonb.type(Object.class).toJsonPretty(any) }
103
103
*
104
104
* @param any The object to return as json string in pretty format
105
105
* @return Return json content in pretty format for the given object.
106
106
*/
107
107
String toJsonPretty (Object any );
108
108
109
+ /**
110
+ * Return the value as json content in bytes form.
111
+ * <p>
112
+ * This is a convenience method for {@code jsonb.type(Object.class).toJsonBytes(any) }
113
+ */
114
+ byte [] toJsonBytes (Object any );
115
+
116
+ /**
117
+ * Write to the given writer.
118
+ * <p>
119
+ * This is a convenience method for {@code jsonb.type(Object.class).toJson(any, writer) }
120
+ */
121
+ void toJson (Object any , Writer writer );
122
+
123
+ /**
124
+ * Write to the given outputStream.
125
+ * <p>
126
+ * This is a convenience method for {@code jsonb.type(Object.class).toJsonBytes(any, outputStream) }
127
+ */
128
+ void toJson (Object any , OutputStream outputStream );
129
+
109
130
/**
110
131
* Return the JsonType used to read and write json for the given class.
111
132
*
112
- * <h3>Examples </h3>
133
+ * <h3>fromJson() example </h3>
113
134
* <pre>{@code
114
135
*
115
- * JsonType<Customer> customerType = jsonb.type(Customer.class)
136
+ * Customer customer = jsonb
137
+ * .type(Customer.class)
138
+ * .fromJson(jsonContent);
116
139
*
117
- * Customer customer = ...
118
- * customerType.toJson(customer);
119
140
*
120
- * JsonType<List<Customer>> customerListType = customerType.list()
141
+ * // list
142
+ * List<Customer> customers = jsonb
143
+ * .type(Customer.class)
144
+ * .list()
145
+ * .fromJson(jsonContent);
146
+ *
147
+ * }</pre>
148
+ *
149
+ * <h3>toJson() example</h3>
150
+ * <pre>{@code
151
+ *
152
+ * Customer customer = ...
121
153
*
122
- * List<Customer> customers = ...
123
- * customerListType.toJson(customers);
154
+ * String jsonContent = jsonb
155
+ * .type(Customer.class)
156
+ * .toJson(customer);
124
157
*
125
158
* }</pre>
126
159
*
@@ -129,6 +162,21 @@ static Builder newBuilder() {
129
162
* We can use <code>type(Object.class)</code> when we don't know the specific type that is being
130
163
* written toJson or read fromJson.
131
164
* <p>
165
+ *
166
+ * <h3>Object toJson()</h3>
167
+ * <pre>{@code
168
+ *
169
+ * Object any = ...
170
+ *
171
+ * String jsonContent = jsonb
172
+ * .type(Object.class)
173
+ * .toJson(any);
174
+ *
175
+ * // the same as
176
+ * String jsonContent = jsonb.toJson(any);
177
+ *
178
+ * }</pre>
179
+ * <p>
132
180
* When using <code>Object.class</code> and writing <code>toJson()</code> then the underlying JsonAdapter
133
181
* is determined dynamically based on the type of the object value passed in.
134
182
* <p>
@@ -158,6 +206,20 @@ static Builder newBuilder() {
158
206
* <p>
159
207
* We can use <code>type(Object.class)</code> when we don't know the specific type that is being
160
208
* written toJson or read fromJson.
209
+ *
210
+ * <h3>Object toJson()</h3>
211
+ * <pre>{@code
212
+ *
213
+ * Object any = ...
214
+ *
215
+ * String jsonContent = jsonb
216
+ * .type(Object.class)
217
+ * .toJson(any);
218
+ *
219
+ * // the same as
220
+ * String jsonContent = jsonb.toJson(any);
221
+ *
222
+ * }</pre>
161
223
* <p>
162
224
* When using <code>Object.class</code> and writing <code>toJson()</code> then the underlying JsonAdapter
163
225
* is determined dynamically based on the type of the object value passed in.
0 commit comments