1
- package io .avaje .json .simple ;
1
+ package io .avaje .json .mapper ;
2
2
3
3
import io .avaje .json .JsonAdapter ;
4
4
import io .avaje .json .JsonReader ;
20
20
* This supports the basic Java types of String, Boolean, Integer, Long, Double and
21
21
* Maps and List of these.
22
22
* <p>
23
+ * If avaje-jsonb is available then you will use that and NOT use this JsonMapper at all.
24
+ * This JsonMapper is intended to be used by code that ONLY wants to depend on avaje-json-core
25
+ * and process the basic Java types or provide its own JsonAdapters.
26
+ * <p>
23
27
* For full support with more types and binding to custom types use avaje-jsonb instead.
24
28
*
25
29
* <h3>Example</h3>
26
30
* <pre>{@code
27
31
*
28
- * static final SimpleMapper simpleMapper = SimpleMapper .builder().build();
32
+ * static final JsonMapper jsonMapper = JsonMapper .builder().build();
29
33
*
30
34
* Map<String, Long> map = new LinkedHashMap<>();
31
35
* map.put("one", 45L);
32
36
* map.put("two", 93L);
33
37
*
34
- * String asJson = simpleMapper .toJson(map);
38
+ * String asJson = jsonMapper .toJson(map);
35
39
*
36
40
* }</pre>
37
41
*/
38
- public interface SimpleMapper {
42
+ public interface JsonMapper {
39
43
40
44
/**
41
- * Create a new builder for SimpleMapper .
45
+ * Create a new builder for JsonMapper .
42
46
*/
43
47
static Builder builder () {
44
- return new DSimpleMapperBuilder ();
48
+ return new DJsonMapperBuilder ();
45
49
}
46
50
47
51
/**
@@ -141,14 +145,17 @@ static Builder builder() {
141
145
* Return a Type specific mapper using a function that creates a JsonAdapter.
142
146
* <p>
143
147
* Often the adapterFunction is the constructor of the custom JsonAdapter where
144
- * the constructor takes SimpleMapper as the only argument.
148
+ * the constructor takes JsonMapper as the only argument.
145
149
*
146
150
* @param adapterFunction The function that creates a JsonAdapter.
147
151
* @param <T> The type of the class to map to/from json.
148
152
* @return The Type specific mapper.
149
153
*/
150
- <T > Type <T > type (Function <SimpleMapper , JsonAdapter <T >> adapterFunction );
154
+ <T > Type <T > type (Function <JsonMapper , JsonAdapter <T >> adapterFunction );
151
155
156
+ /**
157
+ * Return the map wrapped via JsonExtract to make extracting values easier.
158
+ */
152
159
default JsonExtract extract (Map <String , Object > map ) {
153
160
return new DExtract (map );
154
161
}
@@ -170,7 +177,7 @@ interface Builder {
170
177
/**
171
178
* Build and return the JsonNodeMapper.
172
179
*/
173
- SimpleMapper build ();
180
+ JsonMapper build ();
174
181
}
175
182
176
183
/**
0 commit comments