@@ -113,9 +113,9 @@ protected Object readResolve() {
113
113
}
114
114
115
115
/*
116
- /**********************************************************
116
+ /**********************************************************************
117
117
/* Life-cycle, constructors
118
- /**********************************************************
118
+ /**********************************************************************
119
119
*/
120
120
121
121
public JsonMapper () {
@@ -131,9 +131,9 @@ public JsonMapper(Builder b) {
131
131
}
132
132
133
133
/*
134
- /**********************************************************
134
+ /**********************************************************************
135
135
/* Life-cycle, builders
136
- /**********************************************************
136
+ /**********************************************************************
137
137
*/
138
138
139
139
public static JsonMapper .Builder builder () {
@@ -151,9 +151,25 @@ public JsonMapper.Builder rebuild() {
151
151
}
152
152
153
153
/*
154
- /**********************************************************
154
+ /**********************************************************************
155
+ /* Life-cycle, shared "vanilla" (default configuration) instance
156
+ /**********************************************************************
157
+ */
158
+
159
+ /**
160
+ * Accessor method for getting globally shared "default" {@link JsonMapper}
161
+ * instance: one that has default configuration, no modules registered, no
162
+ * config overrides. Usable mostly when dealing "untyped" or Tree-style
163
+ * content reading and writing.
164
+ */
165
+ public static JsonMapper shared () {
166
+ return SharedWrapper .wrapped ();
167
+ }
168
+
169
+ /*
170
+ /**********************************************************************
155
171
/* Standard method overrides
156
- /**********************************************************
172
+ /**********************************************************************
157
173
*/
158
174
159
175
@ Override
@@ -179,4 +195,20 @@ public boolean isEnabled(JsonReadFeature f) {
179
195
public boolean isEnabled (JsonWriteFeature f ) {
180
196
return _serializationConfig .hasFormatFeature (f );
181
197
}
198
+
199
+ /*
200
+ /**********************************************************
201
+ /* Helper class(es)
202
+ /**********************************************************
203
+ */
204
+
205
+ /**
206
+ * Helper class to contain dynamically constructed "shared" instance of
207
+ * mapper, should one be needed via {@link #shared}.
208
+ */
209
+ private final static class SharedWrapper {
210
+ private final static JsonMapper MAPPER = JsonMapper .builder ().build ();
211
+
212
+ public static JsonMapper wrapped () { return MAPPER ; }
213
+ }
182
214
}
0 commit comments