@@ -232,22 +232,21 @@ public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt)
232
232
return (Collection <Object >) _valueInstantiator .createUsingDelegate (ctxt ,
233
233
_delegateDeserializer .deserialize (p , ctxt ));
234
234
}
235
+ // 16-May-2020, tatu: As per [dataformats-text#199] need to first check for
236
+ // possible Array-coercion and only after that String coercion
237
+ if (p .isExpectedStartArrayToken ()) {
238
+ return _deserializeFromArray (p , ctxt , createDefaultInstance (ctxt ));
239
+ }
235
240
// Empty String may be ok; bit tricky to check, however, since
236
241
// there is also possibility of "auto-wrapping" of single-element arrays.
237
242
// Hence we only accept empty String here.
238
243
if (p .hasToken (JsonToken .VALUE_STRING )) {
239
- // 16-May-2020, tatu: As [dataformats-text#199] need to avoid blocking
240
- // check to `isExpectedStartArrayToken()` (needed for CSV in-field array/list logic)
241
- // ... alas, trying to do this here leads to 2 unit test regressions so will
242
- // need to figure out safer mechanism.
243
- // if (_valueInstantiator.canCreateFromString()) {
244
- String str = p .getText ();
245
- if (str .length () == 0 ) {
246
- return (Collection <Object >) _valueInstantiator .createFromString (ctxt , str );
247
- // }
244
+ String str = p .getText ();
245
+ if (str .length () == 0 ) {
246
+ return (Collection <Object >) _valueInstantiator .createFromString (ctxt , str );
248
247
}
249
248
}
250
- return deserialize (p , ctxt , createDefaultInstance (ctxt ));
249
+ return handleNonArray (p , ctxt , createDefaultInstance (ctxt ));
251
250
}
252
251
253
252
/**
@@ -266,9 +265,28 @@ public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt,
266
265
throws IOException
267
266
{
268
267
// Ok: must point to START_ARRAY (or equivalent)
269
- if (! p .isExpectedStartArrayToken ()) {
270
- return handleNonArray (p , ctxt , result );
268
+ if (p .isExpectedStartArrayToken ()) {
269
+ return _deserializeFromArray (p , ctxt , result );
271
270
}
271
+ return handleNonArray (p , ctxt , result );
272
+ }
273
+
274
+ @ Override
275
+ public Object deserializeWithType (JsonParser p , DeserializationContext ctxt ,
276
+ TypeDeserializer typeDeserializer )
277
+ throws IOException
278
+ {
279
+ // In future could check current token... for now this should be enough:
280
+ return typeDeserializer .deserializeTypedFromArray (p , ctxt );
281
+ }
282
+
283
+ /**
284
+ * @since 2.12
285
+ */
286
+ protected Collection <Object > _deserializeFromArray (JsonParser p , DeserializationContext ctxt ,
287
+ Collection <Object > result )
288
+ throws IOException
289
+ {
272
290
// [databind#631]: Assign current value, to be accessible by custom serializers
273
291
p .setCurrentValue (result );
274
292
@@ -310,15 +328,6 @@ public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt,
310
328
return result ;
311
329
}
312
330
313
- @ Override
314
- public Object deserializeWithType (JsonParser p , DeserializationContext ctxt ,
315
- TypeDeserializer typeDeserializer )
316
- throws IOException
317
- {
318
- // In future could check current token... for now this should be enough:
319
- return typeDeserializer .deserializeTypedFromArray (p , ctxt );
320
- }
321
-
322
331
/**
323
332
* Helper method called when current token is no START_ARRAY. Will either
324
333
* throw an exception, or try to handle value as if member of implicit
0 commit comments