or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced-features.mdannotations.mdconfiguration.mddeserialization.mdindex.mdjson-tree-model.mdmodules.mdobject-mapping.mdserialization.mdtype-system.md

deserialization.mddocs/

0

# Deserialization

1

2

Jackson's deserialization framework provides a flexible and extensible system for converting JSON to Java objects. The framework is built around JsonDeserializer implementations, DeserializationContext for processing context, and various factory and configuration classes that control the deserialization process.

3

4

## JsonDeserializer

5

6

JsonDeserializer is the abstract base class for all deserializers that convert JSON to Java objects.

7

8

```java { .api }

9

public abstract class JsonDeserializer<T> {

10

// Core deserialization method

11

public abstract T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException;

12

13

// Type-aware deserialization (for polymorphic types)

14

public T deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException;

15

16

// Null and empty value handling

17

public T getNullValue(DeserializationContext ctxt) throws JsonMappingException;

18

public T getEmptyValue(DeserializationContext ctxt) throws JsonMappingException;

19

public AccessPattern getNullAccessPattern();

20

public AccessPattern getEmptyAccessPattern();

21

22

// Missing value handling (for creator parameters)

23

public Object getAbsentValue(DeserializationContext ctxt) throws JsonMappingException;

24

25

// Metadata methods

26

public Class<?> handledType();

27

public LogicalType logicalType();

28

public boolean isCachable();

29

public JsonDeserializer<?> getDelegatee();

30

public Collection<Object> getKnownPropertyNames();

31

32

// Object identity support

33

public ObjectIdReader getObjectIdReader();

34

35

// Contextual deserialization

36

public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException;

37

38

// Resolution support

39

public void resolve(DeserializationContext ctxt) throws JsonMappingException;

40

41

// Replacement support

42

public JsonDeserializer<?> replaceDelegatee(JsonDeserializer<?> delegatee);

43

44

// Unwrapping support (for @JsonUnwrapped)

45

public boolean isUnwrappingDeserializer();

46

public JsonDeserializer<T> unwrappingDeserializer(NameTransformer unwrapper);

47

48

// Update support (for merging/updating existing objects)

49

public SettableBeanProperty findBackReference(String refName);

50

public Boolean supportsUpdate(DeserializationConfig config);

51

52

// Marker classes for None values

53

public static abstract class None extends JsonDeserializer<Object> { }

54

}

55

```

56

57

## DeserializationContext

58

59

DeserializationContext provides context and utility methods for deserializers during the deserialization process.

60

61

```java { .api }

62

public abstract class DeserializationContext extends DatabindContext {

63

// Value reading

64

public abstract Object readValue(JsonParser p, JavaType valueType) throws IOException;

65

public abstract Object readValue(JsonParser p, Class<?> valueType) throws IOException;

66

public abstract Object readPropertyValue(JsonParser p, BeanProperty prop, JavaType valueType) throws IOException;

67

public abstract Object readPropertyValue(JsonParser p, BeanProperty prop, Class<?> valueType) throws IOException;

68

69

// Deserializer lookup

70

public abstract JsonDeserializer<Object> findContextualValueDeserializer(JavaType type, BeanProperty prop) throws JsonMappingException;

71

public abstract JsonDeserializer<Object> findKeyDeserializer(JavaType keyType, BeanProperty prop) throws JsonMappingException;

72

public final JsonDeserializer<Object> findRootValueDeserializer(JavaType valueType) throws JsonMappingException;

73

74

// Null value providers

75

public abstract JsonDeserializer<Object> findNullValueDeserializer(BeanProperty prop) throws JsonMappingException;

76

77

// Object construction

78

public abstract Object leaseObjectBuffer();

79

public abstract void returnObjectBuffer(Object buf);

80

public abstract Object[] leaseObjectBuffer(int minSize);

81

public abstract void returnObjectBuffer(Object[] buf);

82

83

// Parser utilities

84

public JsonParser getParser();

85

public final JsonLocation getCurrentLocation();

86

public final JsonToken getCurrentToken();

87

public final JsonStreamContext getParsingContext();

88

89

// Problem handling

90

public abstract void reportWrongTokenException(JavaType targetType, JsonToken expToken, String msg, Object... msgArgs) throws JsonMappingException;

91

public abstract void reportMissingContent(String msg, Object... msgArgs) throws JsonMappingException;

92

public abstract Object reportInputMismatch(BeanProperty prop, String msg, Object... msgArgs) throws JsonMappingException;

93

public abstract Object reportInputMismatch(Class<?> targetType, String msg, Object... msgArgs) throws JsonMappingException;

94

public abstract Object reportInputMismatch(JavaType targetType, String msg, Object... msgArgs) throws JsonMappingException;

95

public abstract Object reportBadCoercion(JsonDeserializer<?> src, Class<?> targetType, Object inputValue, String msg, Object... msgArgs) throws JsonMappingException;

96

public abstract JsonMappingException wrongTokenException(JsonParser p, JavaType targetType, JsonToken expToken, String extra) throws JsonMappingException;

97

public abstract JsonMappingException weirdStringException(String value, Class<?> instClass, String msgFormat, Object... msgArgs) throws JsonMappingException;

98

public abstract JsonMappingException weirdNumberException(Number value, Class<?> instClass, String msg) throws JsonMappingException;

99

public abstract JsonMappingException weirdKeyException(Class<?> keyClass, String keyValue, String msg) throws JsonMappingException;

100

public abstract JsonMappingException instantiationException(Class<?> instClass, Throwable cause) throws JsonMappingException;

101

public abstract JsonMappingException instantiationException(Class<?> instClass, String msg) throws JsonMappingException;

102

public abstract JsonMappingException invalidTypeIdException(JavaType baseType, String typeId, String extraDesc) throws JsonMappingException;

103

public abstract JsonMappingException missingTypeIdException(JavaType baseType, String extraDesc) throws JsonMappingException;

104

105

// Unknown property handling

106

public abstract boolean handleUnknownProperty(JsonParser p, JsonDeserializer<?> deser, Object instanceOrClass, String propName) throws IOException;

107

108

// Ignorable types

109

public abstract boolean isEnabled(DeserializationFeature feat);

110

public final boolean isEnabled(MapperFeature feat);

111

public final boolean isEnabled(JsonParser.Feature feat);

112

113

// Configuration access

114

public abstract DeserializationConfig getConfig();

115

116

// View support

117

public final Class<?> getActiveView();

118

119

// Locale and timezone

120

public final Locale getLocale();

121

public final TimeZone getTimeZone();

122

123

// Date format

124

public final DateFormat getDateFormat();

125

126

// Attributes

127

public abstract Object getAttribute(Object key);

128

public abstract DeserializationContext setAttribute(Object key, Object value);

129

130

// Type factory

131

public final TypeFactory getTypeFactory();

132

133

// Object construction utilities

134

public Class<?> findClass(String className) throws ClassNotFoundException;

135

136

// Coercion

137

public CoercionAction findCoercionAction(LogicalType logicalType, Class<?> rawTargetType, CoercionInputShape inputShape);

138

public CoercionAction findCoercionFromBlankString(LogicalType logicalType, Class<?> rawTargetType, CoercionAction actionIfBlankNotAllowed);

139

140

// Array handling

141

public final boolean hasSomeOfFeatures(int featureMask);

142

143

// Object identity

144

public abstract ReadableObjectId findObjectId(Object id, ObjectIdGenerator<?> generator, ObjectIdResolver resolver);

145

public abstract void checkUnresolvedObjectId() throws UnresolvedForwardReference;

146

147

// Buffer management for arrays

148

public final ObjectBuffer leaseObjectBuffer();

149

public final void returnObjectBuffer(ObjectBuffer buf);

150

151

// String building

152

public StringBuilder constructStringBuilder();

153

public String constructString();

154

155

// Number parsing

156

public final int extractScalarFromObject(JsonParser p, JsonDeserializer<?> deser, Class<?> scalarType) throws IOException;

157

}

158

```

159

160

## Standard Deserializers

161

162

Jackson provides standard deserializers for common Java types.

163

164

### StdDeserializer

165

166

```java { .api }

167

public abstract class StdDeserializer<T> extends JsonDeserializer<T> implements Serializable {

168

// Construction

169

protected StdDeserializer(Class<?> vc);

170

protected StdDeserializer(JavaType valueType);

171

protected StdDeserializer(StdDeserializer<?> src);

172

173

// Type information

174

public Class<?> handledType();

175

public JavaType getValueType();

176

public JavaType getValueType(DeserializationContext ctxt);

177

178

// Value extraction utilities

179

protected final boolean _parseBooleanPrimitive(JsonParser p, DeserializationContext ctxt) throws IOException;

180

protected final Boolean _parseBoolean(JsonParser p, DeserializationContext ctxt) throws IOException;

181

protected final Boolean _parseBoolean(JsonParser p, DeserializationContext ctxt, Class<?> targetType) throws IOException;

182

protected final int _parseIntPrimitive(JsonParser p, DeserializationContext ctxt) throws IOException;

183

protected final Integer _parseInteger(JsonParser p, DeserializationContext ctxt) throws IOException;

184

protected final Integer _parseInteger(JsonParser p, DeserializationContext ctxt, Class<?> targetType) throws IOException;

185

protected final long _parseLongPrimitive(JsonParser p, DeserializationContext ctxt) throws IOException;

186

protected final Long _parseLong(JsonParser p, DeserializationContext ctxt) throws IOException;

187

protected final Long _parseLong(JsonParser p, DeserializationContext ctxt, Class<?> targetType) throws IOException;

188

protected final float _parseFloatPrimitive(JsonParser p, DeserializationContext ctxt) throws IOException;

189

protected final Float _parseFloat(JsonParser p, DeserializationContext ctxt) throws IOException;

190

protected final double _parseDoublePrimitive(JsonParser p, DeserializationContext ctxt) throws IOException;

191

protected final Double _parseDouble(JsonParser p, DeserializationContext ctxt) throws IOException;

192

protected final Date _parseDate(JsonParser p, DeserializationContext ctxt) throws IOException;

193

protected final String _parseString(JsonParser p, DeserializationContext ctxt) throws IOException;

194

195

// String coercion utilities

196

protected T _deserializeFromString(JsonParser p, DeserializationContext ctxt) throws IOException;

197

protected T _deserializeFromArray(JsonParser p, DeserializationContext ctxt) throws IOException;

198

protected T _deserializeWrappedValue(JsonParser p, DeserializationContext ctxt) throws IOException;

199

200

// Exception handling utilities

201

protected JsonMappingException wrapAndThrow(Throwable t, Object ref, String fieldName) throws JsonMappingException;

202

protected JsonMappingException wrapAndThrow(Throwable t, Object ref, int index) throws JsonMappingException;

203

204

// Null handling

205

protected void handleUnknownProperty(JsonParser p, DeserializationContext ctxt, Object instanceOrClass, String propName) throws IOException;

206

protected void handleMissingEndArrayForSingle(JsonParser p, DeserializationContext ctxt) throws IOException;

207

208

// Type checking

209

protected final boolean _hasTextualNull(String value);

210

protected final boolean _isEmptyOrTextualNull(String value);

211

protected final boolean _isNegInf(String text);

212

protected final boolean _isPosInf(String text);

213

protected final boolean _isNaN(String text);

214

215

// Coercion support

216

protected Object _coerceEmptyString(DeserializationContext ctxt, boolean isEmpty) throws JsonMappingException;

217

protected Object _coerceTextualNull(DeserializationContext ctxt, boolean isPrimitive) throws JsonMappingException;

218

protected Object _coerceIntegral(JsonParser p, DeserializationContext ctxt) throws IOException;

219

protected Object _coerceTextualNull(DeserializationContext ctxt, boolean isPrimitive) throws JsonMappingException;

220

221

// Logging

222

protected void _reportFailedNullCoerce(DeserializationContext ctxt, boolean state, Enum<?> feature, String inputDesc) throws JsonMappingException;

223

}

224

225

// Scalar deserializers

226

public abstract class StdScalarDeserializer<T> extends StdDeserializer<T> {

227

protected StdScalarDeserializer(Class<?> vc);

228

protected StdScalarDeserializer(JavaType valueType);

229

protected StdScalarDeserializer(StdScalarDeserializer<?> src);

230

231

public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException;

232

public abstract LogicalType logicalType();

233

}

234

```

235

236

### Container Deserializers

237

238

```java { .api }

239

// Collection deserializer

240

public class CollectionDeserializer extends ContainerDeserializerBase<Collection<Object>> implements ContextualDeserializer {

241

// Construction

242

public CollectionDeserializer(JavaType collectionType, JsonDeserializer<Object> valueDeser, TypeDeserializer valueTypeDeser, ValueInstantiator valueInstantiator);

243

public CollectionDeserializer(JavaType collectionType, JsonDeserializer<Object> valueDeser, TypeDeserializer valueTypeDeser, ValueInstantiator valueInstantiator, JsonDeserializer<Object> delegateDeser);

244

245

// Contextualization

246

public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException;

247

248

// Deserialization

249

public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException;

250

public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt, Collection<Object> result) throws IOException;

251

252

// Value instantiation

253

public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException;

254

255

// Type information

256

public JavaType getContentType();

257

public JsonDeserializer<Object> getContentDeserializer();

258

259

// Logical type

260

public LogicalType logicalType();

261

262

// Null/empty handling

263

public boolean isCachable();

264

265

// Support methods

266

public Collection<Object> handleNonArray(JsonParser p, DeserializationContext ctxt, Collection<Object> result) throws IOException;

267

}

268

269

// Array deserializer

270

public class ObjectArrayDeserializer extends ContainerDeserializerBase<Object[]> implements ContextualDeserializer {

271

// Construction

272

public ObjectArrayDeserializer(JavaType arrayType, JsonDeserializer<Object> elemDeser, TypeDeserializer elemTypeDeser);

273

274

// Contextualization

275

public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException;

276

277

// Deserialization

278

public Object[] deserialize(JsonParser p, DeserializationContext ctxt) throws IOException;

279

public Object[] deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException;

280

281

// Content type

282

public JavaType getContentType();

283

public JsonDeserializer<Object> getContentDeserializer();

284

285

// Logical type

286

public LogicalType logicalType();

287

}

288

289

// Map deserializer

290

public class MapDeserializer extends ContainerDeserializerBase<Map<Object, Object>> implements ContextualDeserializer, ResolvableDeserializer {

291

// Construction

292

public MapDeserializer(JavaType mapType, ValueInstantiator valueInstantiator, KeyDeserializer keyDeser, JsonDeserializer<Object> valueDeser, TypeDeserializer valueTypeDeser);

293

294

// Contextualization

295

public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException;

296

297

// Resolution

298

public void resolve(DeserializationContext ctxt) throws JsonMappingException;

299

300

// Deserialization

301

public Map<Object, Object> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException;

302

public Map<Object, Object> deserialize(JsonParser p, DeserializationContext ctxt, Map<Object, Object> result) throws IOException;

303

public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException;

304

305

// Content information

306

public JavaType getContentType();

307

public JsonDeserializer<Object> getContentDeserializer();

308

309

// Key information

310

public KeyDeserializer getKeyDeserializer();

311

312

// Logical type

313

public LogicalType logicalType();

314

315

// Support methods

316

protected void wrapAndThrow(Throwable t, Object ref, String fieldName) throws JsonMappingException;

317

}

318

```

319

320

## Bean Deserialization

321

322

### BeanDeserializer

323

324

```java { .api }

325

public class BeanDeserializer extends BeanDeserializerBase implements Serializable {

326

// Construction

327

public BeanDeserializer(BeanDeserializerBuilder builder, BeanDescription beanDesc, BeanPropertyMap properties, Map<String, SettableBeanProperty> backRefs, HashSet<String> ignorableProps, boolean ignoreAllUnknown, Set<String> includableProps, boolean hasViews);

328

protected BeanDeserializer(BeanDeserializerBase src);

329

protected BeanDeserializer(BeanDeserializerBase src, boolean ignoreAllUnknown);

330

protected BeanDeserializer(BeanDeserializerBase src, NameTransformer unwrapper);

331

protected BeanDeserializer(BeanDeserializerBase src, ObjectIdReader oir);

332

protected BeanDeserializerBase(BeanDeserializerBase src, Set<String> ignorableProps);

333

protected BeanDeserializer(BeanDeserializerBase src, BeanPropertyMap props);

334

335

// Deserialization

336

public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException;

337

public Object deserialize(JsonParser p, DeserializationContext ctxt, Object bean) throws IOException;

338

339

// Deserialization from different structures

340

protected Object _deserializeUsingPropertyBased(JsonParser p, DeserializationContext ctxt) throws IOException;

341

public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) throws IOException;

342

protected Object _deserializeFromArray(JsonParser p, DeserializationContext ctxt) throws IOException;

343

protected final Object _deserializeFromString(JsonParser p, DeserializationContext ctxt) throws IOException;

344

protected Object _deserializeFromNumber(JsonParser p, DeserializationContext ctxt) throws IOException;

345

protected Object _deserializeOther(JsonParser p, DeserializationContext ctxt, JsonToken t) throws IOException;

346

347

// Unwrapping support

348

public JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper);

349

350

// Replacement

351

public BeanDeserializer withObjectIdReader(ObjectIdReader oir);

352

public BeanDeserializer withByNameInclusion(Set<String> ignorableProps, Set<String> includableProps);

353

public BeanDeserializerBase withIgnoreAllUnknown(boolean ignoreUnknown);

354

public BeanDeserializerBase withBeanProperties(BeanPropertyMap props);

355

356

// Support methods

357

protected Object deserializeWithView(JsonParser p, DeserializationContext ctxt, Object bean, Class<?> activeView) throws IOException;

358

protected Object deserializeWithExternalTypeId(JsonParser p, DeserializationContext ctxt) throws IOException;

359

protected Object deserializeWithExternalTypeId(JsonParser p, DeserializationContext ctxt, Object bean) throws IOException;

360

}

361

362

public abstract class BeanDeserializerBase extends StdDeserializer<Object> implements ContextualDeserializer, ResolvableDeserializer, Serializable {

363

// Bean metadata

364

protected final JavaType _beanType;

365

protected final BeanPropertyMap _beanProperties;

366

protected final ValueInstantiator _valueInstantiator;

367

368

// Special properties

369

protected JsonDeserializer<Object> _delegateDeserializer;

370

protected JsonDeserializer<Object> _arrayDelegateDeserializer;

371

protected PropertyBasedCreator _propertyBasedCreator;

372

protected boolean _nonStandardCreation;

373

protected boolean _vanillaProcessing;

374

375

// Ignored and external properties

376

protected final Set<String> _ignorableProps;

377

protected final boolean _ignoreAllUnknown;

378

protected final Set<String> _includableProps;

379

protected SettableAnyProperty _anySetter;

380

protected final Map<String, SettableBeanProperty> _backRefs;

381

382

// View support

383

protected final boolean _hasViews;

384

385

// Object identity

386

protected final ObjectIdReader _objectIdReader;

387

388

// External type handling

389

protected ExternalTypeHandler _externalTypeIdHandler;

390

391

// Deserialization methods

392

public abstract Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException;

393

public abstract Object deserialize(JsonParser p, DeserializationContext ctxt, Object bean) throws IOException;

394

public abstract Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) throws IOException;

395

396

// Metadata access

397

public Class<?> getBeanClass();

398

public JavaType getValueType();

399

public Iterator<SettableBeanProperty> properties();

400

public boolean hasProperty(String propertyName);

401

public SettableBeanProperty findProperty(String propertyName);

402

public SettableBeanProperty findProperty(int propertyIndex);

403

404

// Replacement methods

405

public abstract JsonDeserializer<Object> unwrappingDeserializer(NameTransformer unwrapper);

406

public abstract BeanDeserializerBase withObjectIdReader(ObjectIdReader oir);

407

public abstract BeanDeserializerBase withIgnoreAllUnknown(boolean ignoreUnknown);

408

public abstract BeanDeserializerBase withBeanProperties(BeanPropertyMap props);

409

public abstract BeanDeserializerBase withByNameInclusion(Set<String> ignorableProps, Set<String> includableProps);

410

411

// Contextualization and resolution

412

public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException;

413

public void resolve(DeserializationContext ctxt) throws JsonMappingException;

414

415

// Unknown property handling

416

protected void handleUnknownProperty(JsonParser p, DeserializationContext ctxt, Object beanOrClass, String propName) throws IOException;

417

protected void handleUnknownVanilla(JsonParser p, DeserializationContext ctxt, Object bean, String propName) throws IOException;

418

protected void handleUnknownProperties(DeserializationContext ctxt, Object bean, TokenBuffer unknownTokens) throws IOException;

419

420

// Ignored properties

421

protected void handleIgnoredProperty(JsonParser p, DeserializationContext ctxt, Object beanOrClass, String propName) throws IOException;

422

423

// Type information

424

public LogicalType logicalType();

425

public boolean isCachable();

426

public Boolean supportsUpdate(DeserializationConfig config);

427

428

// Back reference support

429

public SettableBeanProperty findBackReference(String logicalName);

430

431

// Object identity

432

public ObjectIdReader getObjectIdReader();

433

434

// Exception creation

435

protected JsonMappingException wrapAndThrow(Throwable t, Object ref, String fieldName, DeserializationContext ctxt) throws JsonMappingException;

436

protected JsonMappingException wrapAndThrow(Throwable t, Object ref, int index, DeserializationContext ctxt) throws JsonMappingException;

437

}

438

```

439

440

### SettableBeanProperty

441

442

```java { .api }

443

public abstract class SettableBeanProperty implements BeanProperty {

444

// Property metadata

445

protected final PropertyName _propName;

446

protected final JavaType _type;

447

protected final PropertyName _wrapperName;

448

protected final AnnotatedMember _member;

449

protected final Annotations _contextAnnotations;

450

451

// Deserialization

452

protected JsonDeserializer<Object> _valueDeserializer;

453

protected TypeDeserializer _valueTypeDeserializer;

454

protected NullValueProvider _nullProvider;

455

456

// Property index for faster access

457

protected final int _propertyIndex;

458

protected final int _creatorIndex;

459

460

// Views

461

protected Class<?>[] _includeInViews;

462

463

// Construction

464

protected SettableBeanProperty(BeanPropertyDefinition propDef, JavaType type, TypeDeserializer typeDeser, Annotations contextAnnotations);

465

protected SettableBeanProperty(PropertyName propName, JavaType type, PropertyName wrapperName, TypeDeserializer typeDeser, Annotations contextAnnotations, PropertyMetadata metadata);

466

protected SettableBeanProperty(SettableBeanProperty src, JsonDeserializer<?> deser);

467

protected SettableBeanProperty(SettableBeanProperty src, PropertyName newName);

468

469

// Abstract methods

470

public abstract void deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException;

471

public abstract Object deserializeSetAndReturn(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException;

472

public abstract void set(Object instance, Object value) throws IOException;

473

public abstract Object setAndReturn(Object instance, Object value) throws IOException;

474

475

// Replacement methods

476

public abstract SettableBeanProperty withName(PropertyName newName);

477

public abstract SettableBeanProperty withValueDeserializer(JsonDeserializer<?> deser);

478

public abstract SettableBeanProperty withNullProvider(NullValueProvider nva);

479

480

// Assignment

481

public void assignIndex(int index);

482

public void setViews(Class<?>[] views);

483

public void fixAccess(DeserializationConfig config);

484

485

// Metadata access

486

public final String getName();

487

public PropertyName getFullName();

488

public JavaType getType();

489

public PropertyName getWrapperName();

490

public AnnotatedMember getMember();

491

public <A extends Annotation> A getAnnotation(Class<A> acls);

492

public <A extends Annotation> A getContextAnnotation(Class<A> acls);

493

494

// Deserialization access

495

public JsonDeserializer<Object> getValueDeserializer();

496

public TypeDeserializer getValueTypeDeserializer();

497

498

// View support

499

public boolean visibleInView(Class<?> activeView);

500

public boolean hasViews();

501

502

// Property index

503

public int getPropertyIndex();

504

public int getCreatorIndex();

505

506

// Metadata

507

public PropertyMetadata getMetadata();

508

public boolean isRequired();

509

public boolean isInjectionOnly();

510

511

// Value providers

512

public NullValueProvider getNullValueProvider();

513

514

// String representation

515

public String toString();

516

}

517

```

518

519

## Deserializer Factory

520

521

### DeserializerFactory

522

523

```java { .api }

524

public abstract class DeserializerFactory {

525

// Deserializer creation

526

public abstract JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException;

527

public abstract JsonDeserializer<Object> createBuilderBasedDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc, Class<?> builderClass) throws JsonMappingException;

528

529

// Array deserializers

530

public abstract JsonDeserializer<?> createArrayDeserializer(DeserializationContext ctxt, ArrayType type, BeanDescription beanDesc) throws JsonMappingException;

531

532

// Collection deserializers

533

public abstract JsonDeserializer<?> createCollectionDeserializer(DeserializationContext ctxt, CollectionType type, BeanDescription beanDesc) throws JsonMappingException;

534

public abstract JsonDeserializer<?> createCollectionLikeDeserializer(DeserializationContext ctxt, CollectionLikeType type, BeanDescription beanDesc) throws JsonMappingException;

535

536

// Map deserializers

537

public abstract JsonDeserializer<?> createMapDeserializer(DeserializationContext ctxt, MapType type, BeanDescription beanDesc) throws JsonMappingException;

538

public abstract JsonDeserializer<?> createMapLikeDeserializer(DeserializationContext ctxt, MapLikeType type, BeanDescription beanDesc) throws JsonMappingException;

539

540

// Enum deserializers

541

public abstract JsonDeserializer<?> createEnumDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException;

542

543

// Tree deserializer

544

public abstract JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config, JavaType nodeType, BeanDescription beanDesc) throws JsonMappingException;

545

546

// Reference type deserializers

547

public abstract JsonDeserializer<?> createReferenceDeserializer(DeserializationContext ctxt, ReferenceType type, BeanDescription beanDesc) throws JsonMappingException;

548

549

// Type deserializers

550

public abstract TypeDeserializer findTypeDeserializer(DeserializationConfig config, JavaType baseType) throws JsonMappingException;

551

552

// Key deserializers

553

public abstract KeyDeserializer createKeyDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException;

554

555

// Configuration

556

public abstract DeserializerFactory withAdditionalDeserializers(Deserializers additional);

557

public abstract DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional);

558

public abstract DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier);

559

public abstract DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver);

560

public abstract DeserializerFactory withValueInstantiators(ValueInstantiators instantiators);

561

public abstract DeserializerFactory withConfig(DeserializationConfig config);

562

}

563

564

public class BeanDeserializerFactory extends BasicDeserializerFactory implements Serializable {

565

// Singleton instance

566

public static final BeanDeserializerFactory instance;

567

568

// Construction

569

public BeanDeserializerFactory(DeserializerFactoryConfig config);

570

571

// Factory methods

572

public DeserializerFactory withConfig(DeserializationConfig config);

573

public DeserializerFactory withAdditionalDeserializers(Deserializers additional);

574

public DeserializerFactory withAdditionalKeyDeserializers(KeyDeserializers additional);

575

public DeserializerFactory withDeserializerModifier(BeanDeserializerModifier modifier);

576

public DeserializerFactory withAbstractTypeResolver(AbstractTypeResolver resolver);

577

public DeserializerFactory withValueInstantiators(ValueInstantiators instantiators);

578

579

// Bean deserializer creation

580

public JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException;

581

public JsonDeserializer<Object> buildBeanDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException;

582

protected JsonDeserializer<Object> constructBeanDeserializer(DeserializationContext ctxt, BeanDescription beanDesc) throws JsonMappingException;

583

584

// Builder-based deserializers

585

public JsonDeserializer<Object> createBuilderBasedDeserializer(DeserializationContext ctxt, JavaType valueType, BeanDescription beanDesc, Class<?> builderClass) throws JsonMappingException;

586

587

// Property handling

588

protected void addBeanProps(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder) throws JsonMappingException;

589

protected List<SettableBeanProperty> filterBeanProps(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder, List<BeanPropertyDefinition> propDefs, Set<String> ignored) throws JsonMappingException;

590

protected SettableBeanProperty constructSettableProperty(DeserializationContext ctxt, BeanDescription beanDesc, BeanPropertyDefinition propDef, JavaType propType0) throws JsonMappingException;

591

protected SettableBeanProperty constructSetterlessProperty(DeserializationContext ctxt, BeanDescription beanDesc, BeanPropertyDefinition propDef) throws JsonMappingException;

592

593

// Creator handling

594

protected void addObjectIdReader(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder) throws JsonMappingException;

595

protected PropertyBasedCreator _constructPropertyBasedCreator(DeserializationContext ctxt, BeanDescription beanDesc, boolean visibilityForCreators, AnnotationIntrospector intr, CreatorCollector creators) throws JsonMappingException;

596

}

597

```

598

599

## Usage Examples

600

601

### Custom Deserializers

602

603

```java

604

import com.fasterxml.jackson.core.JsonParser;

605

import com.fasterxml.jackson.core.JsonToken;

606

import com.fasterxml.jackson.databind.DeserializationContext;

607

import com.fasterxml.jackson.databind.deser.std.StdDeserializer;

608

609

// Custom deserializer for Person class

610

public class PersonDeserializer extends StdDeserializer<Person> {

611

612

public PersonDeserializer() {

613

this(null);

614

}

615

616

public PersonDeserializer(Class<?> vc) {

617

super(vc);

618

}

619

620

@Override

621

public Person deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

622

JsonToken token = p.getCurrentToken();

623

624

if (token == JsonToken.START_OBJECT) {

625

String firstName = null;

626

String lastName = null;

627

Integer age = null;

628

Date birthDate = null;

629

630

while (p.nextToken() != JsonToken.END_OBJECT) {

631

String fieldName = p.getCurrentName();

632

p.nextToken();

633

634

switch (fieldName) {

635

case "fullName":

636

// Handle "John Doe" format

637

String fullName = p.getText();

638

String[] parts = fullName.split(" ", 2);

639

firstName = parts[0];

640

lastName = parts.length > 1 ? parts[1] : "";

641

break;

642

case "firstName":

643

firstName = p.getText();

644

break;

645

case "lastName":

646

lastName = p.getText();

647

break;

648

case "age":

649

age = p.getIntValue();

650

break;

651

case "birthDate":

652

// Custom date parsing

653

String dateStr = p.getText();

654

try {

655

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

656

birthDate = sdf.parse(dateStr);

657

} catch (ParseException e) {

658

throw new JsonProcessingException("Invalid date format: " + dateStr, p.getCurrentLocation(), e);

659

}

660

break;

661

default:

662

// Skip unknown properties or handle them

663

p.skipChildren();

664

break;

665

}

666

}

667

668

// Validation

669

if (firstName == null) {

670

throw new JsonMappingException(p, "firstName is required");

671

}

672

673

return new Person(firstName, lastName, age, birthDate);

674

675

} else if (token == JsonToken.VALUE_STRING) {

676

// Handle string format like "John Doe,30"

677

String value = p.getText();

678

String[] parts = value.split(",");

679

if (parts.length >= 1) {

680

String[] nameParts = parts[0].split(" ", 2);

681

String firstName = nameParts[0];

682

String lastName = nameParts.length > 1 ? nameParts[1] : "";

683

Integer age = parts.length > 1 ? Integer.parseInt(parts[1].trim()) : null;

684

return new Person(firstName, lastName, age, null);

685

}

686

}

687

688

throw new JsonMappingException(p, "Cannot deserialize Person from " + token);

689

}

690

691

// Handle type information for polymorphic deserialization

692

@Override

693

public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException {

694

return typeDeserializer.deserializeTypedFromObject(p, ctxt);

695

}

696

697

// Provide null value

698

@Override

699

public Person getNullValue(DeserializationContext ctxt) {

700

return new Person("Unknown", "", 0, null);

701

}

702

}

703

704

// Register with ObjectMapper

705

ObjectMapper mapper = new ObjectMapper();

706

SimpleModule module = new SimpleModule();

707

module.addDeserializer(Person.class, new PersonDeserializer());

708

mapper.registerModule(module);

709

710

// Use

711

String json = "{\"fullName\":\"John Doe\",\"age\":30}";

712

Person person = mapper.readValue(json, Person.class);

713

```

714

715

### Contextual Deserializers

716

717

```java

718

// Contextual deserializer that adapts based on annotations

719

public class ConfigurableStringDeserializer extends StdDeserializer<String> implements ContextualDeserializer {

720

721

private final boolean upperCase;

722

private final boolean trim;

723

private final String defaultValue;

724

725

public ConfigurableStringDeserializer() {

726

this(false, false, null);

727

}

728

729

private ConfigurableStringDeserializer(boolean upperCase, boolean trim, String defaultValue) {

730

super(String.class);

731

this.upperCase = upperCase;

732

this.trim = trim;

733

this.defaultValue = defaultValue;

734

}

735

736

@Override

737

public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {

738

if (property != null) {

739

StringFormat ann = property.getAnnotation(StringFormat.class);

740

if (ann != null) {

741

return new ConfigurableStringDeserializer(

742

ann.upperCase(),

743

ann.trim(),

744

ann.defaultValue().isEmpty() ? null : ann.defaultValue()

745

);

746

}

747

}

748

return this;

749

}

750

751

@Override

752

public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

753

String value = p.getValueAsString();

754

755

if (value == null || value.isEmpty()) {

756

return defaultValue;

757

}

758

759

if (trim) {

760

value = value.trim();

761

}

762

763

if (upperCase) {

764

value = value.toUpperCase();

765

}

766

767

return value;

768

}

769

770

@Override

771

public String getNullValue(DeserializationContext ctxt) {

772

return defaultValue;

773

}

774

}

775

776

// Custom annotation

777

@Retention(RetentionPolicy.RUNTIME)

778

@Target(ElementType.FIELD)

779

public @interface StringFormat {

780

boolean upperCase() default false;

781

boolean trim() default true;

782

String defaultValue() default "";

783

}

784

785

// Usage in POJO

786

public class UserData {

787

@StringFormat(upperCase = true, trim = true)

788

private String username;

789

790

@StringFormat(trim = true, defaultValue = "Unknown")

791

private String displayName;

792

793

// getters/setters

794

}

795

```

796

797

### Collection and Map Deserializers

798

799

```java

800

// Custom collection deserializer

801

public class DelimitedStringListDeserializer extends StdDeserializer<List<String>> {

802

803

private final String delimiter;

804

805

public DelimitedStringListDeserializer(String delimiter) {

806

super(List.class);

807

this.delimiter = delimiter;

808

}

809

810

@Override

811

public List<String> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

812

JsonToken token = p.getCurrentToken();

813

814

if (token == JsonToken.VALUE_STRING) {

815

// Parse delimited string

816

String value = p.getText();

817

if (value == null || value.isEmpty()) {

818

return new ArrayList<>();

819

}

820

return Arrays.asList(value.split(Pattern.quote(delimiter)));

821

822

} else if (token == JsonToken.START_ARRAY) {

823

// Standard array parsing

824

List<String> result = new ArrayList<>();

825

while (p.nextToken() != JsonToken.END_ARRAY) {

826

result.add(p.getValueAsString());

827

}

828

return result;

829

}

830

831

throw new JsonMappingException(p, "Expected string or array for delimited list");

832

}

833

834

@Override

835

public List<String> getNullValue(DeserializationContext ctxt) {

836

return new ArrayList<>();

837

}

838

}

839

840

// Custom map deserializer that handles both object and array formats

841

public class FlexibleMapDeserializer extends StdDeserializer<Map<String, Object>> {

842

843

public FlexibleMapDeserializer() {

844

super(Map.class);

845

}

846

847

@Override

848

public Map<String, Object> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

849

JsonToken token = p.getCurrentToken();

850

851

if (token == JsonToken.START_OBJECT) {

852

// Standard object format

853

Map<String, Object> result = new LinkedHashMap<>();

854

while (p.nextToken() != JsonToken.END_OBJECT) {

855

String key = p.getCurrentName();

856

p.nextToken();

857

Object value = ctxt.readValue(p, Object.class);

858

result.put(key, value);

859

}

860

return result;

861

862

} else if (token == JsonToken.START_ARRAY) {

863

// Array of key-value pairs: [["key1", "value1"], ["key2", "value2"]]

864

Map<String, Object> result = new LinkedHashMap<>();

865

while (p.nextToken() != JsonToken.END_ARRAY) {

866

if (p.getCurrentToken() == JsonToken.START_ARRAY) {

867

p.nextToken(); // key

868

String key = p.getValueAsString();

869

p.nextToken(); // value

870

Object value = ctxt.readValue(p, Object.class);

871

p.nextToken(); // END_ARRAY

872

result.put(key, value);

873

}

874

}

875

return result;

876

}

877

878

throw new JsonMappingException(p, "Expected object or array for flexible map");

879

}

880

}

881

```

882

883

### Bean Deserialization with Custom Properties

884

885

```java

886

// Custom settable property for computed fields

887

public class ComputedSettableBeanProperty extends SettableBeanProperty {

888

889

private final BiConsumer<Object, Object> setter;

890

private final Function<String, Object> valueConverter;

891

892

public ComputedSettableBeanProperty(BeanPropertyDefinition propDef, JavaType type,

893

BiConsumer<Object, Object> setter,

894

Function<String, Object> valueConverter) {

895

super(propDef, type, null, null, null);

896

this.setter = setter;

897

this.valueConverter = valueConverter;

898

}

899

900

@Override

901

public void deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException {

902

Object value = deserialize(p, ctxt);

903

if (value != null) {

904

setter.accept(instance, value);

905

}

906

}

907

908

@Override

909

public Object deserializeSetAndReturn(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException {

910

deserializeAndSet(p, ctxt, instance);

911

return instance;

912

}

913

914

@Override

915

public void set(Object instance, Object value) throws IOException {

916

setter.accept(instance, value);

917

}

918

919

@Override

920

public Object setAndReturn(Object instance, Object value) throws IOException {

921

set(instance, value);

922

return instance;

923

}

924

925

public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

926

String stringValue = p.getValueAsString();

927

return valueConverter != null ? valueConverter.apply(stringValue) : stringValue;

928

}

929

930

@Override

931

public SettableBeanProperty withName(PropertyName newName) {

932

return this; // Immutable for simplicity

933

}

934

935

@Override

936

public SettableBeanProperty withValueDeserializer(JsonDeserializer<?> deser) {

937

return this; // Ignore for computed properties

938

}

939

940

@Override

941

public SettableBeanProperty withNullProvider(NullValueProvider nva) {

942

return this;

943

}

944

}

945

946

// Bean deserializer modifier to add computed properties

947

public class ComputedPropertiesDeserializerModifier extends BeanDeserializerModifier {

948

949

@Override

950

public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BeanDescription beanDesc, BeanDeserializerBuilder builder) {

951

Class<?> beanClass = beanDesc.getBeanClass();

952

953

if (beanClass == Person.class) {

954

// Add computed age from birthDate property

955

SimpleBeanPropertyDefinition ageFromBirthDate = SimpleBeanPropertyDefinition.construct(

956

config, null, new PropertyName("ageFromBirthDate"));

957

958

ComputedSettableBeanProperty computedProp = new ComputedSettableBeanProperty(

959

ageFromBirthDate,

960

config.getTypeFactory().constructType(Integer.class),

961

(person, dateStr) -> {

962

try {

963

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

964

Date birthDate = sdf.parse((String) dateStr);

965

long ageInMillis = System.currentTimeMillis() - birthDate.getTime();

966

int years = (int) (ageInMillis / (365.25 * 24 * 60 * 60 * 1000));

967

((Person) person).setAge(years);

968

} catch (Exception e) {

969

// Handle parsing errors

970

}

971

},

972

null // No conversion needed, handled in setter

973

);

974

975

builder.addProperty(computedProp);

976

}

977

978

return builder;

979

}

980

}

981

```

982

983

### Error Handling and Validation

984

985

```java

986

// Deserializer with validation

987

public class ValidatedEmailDeserializer extends StdDeserializer<String> {

988

989

private static final Pattern EMAIL_PATTERN =

990

Pattern.compile("^[A-Za-z0-9+_.-]+@([A-Za-z0-9.-]+\\.[A-Za-z]{2,})$");

991

992

public ValidatedEmailDeserializer() {

993

super(String.class);

994

}

995

996

@Override

997

public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {

998

String email = p.getValueAsString();

999

1000

if (email == null || email.isEmpty()) {

1001

throw new JsonMappingException(p, "Email cannot be null or empty");

1002

}

1003

1004

if (!EMAIL_PATTERN.matcher(email).matches()) {

1005

throw new JsonMappingException(p, "Invalid email format: " + email);

1006

}

1007

1008

return email.toLowerCase(); // Normalize

1009

}

1010

1011

@Override

1012

public String getNullValue(DeserializationContext ctxt) throws JsonMappingException {

1013

throw new JsonMappingException(ctxt.getParser(), "Email cannot be null");

1014

}

1015

}

1016

1017

// Problem handler for graceful error handling

1018

public class LoggingDeserializationProblemHandler extends DeserializationProblemHandler {

1019

1020

private static final Logger logger = LoggerFactory.getLogger(LoggingDeserializationProblemHandler.class);

1021

1022

@Override

1023

public boolean handleUnknownProperty(DeserializationContext ctxt, JsonParser p, JsonDeserializer<?> deserializer, Object beanOrClass, String propertyName) throws IOException {

1024

logger.warn("Unknown property '{}' in {}, skipping", propertyName, beanOrClass.getClass().getSimpleName());

1025

p.skipChildren(); // Skip the value

1026

return true; // Handled

1027

}

1028

1029

@Override

1030

public Object handleInstantiationProblem(DeserializationContext ctxt, Class<?> instClass, Object argument, Throwable t) throws IOException {

1031

logger.error("Failed to instantiate {}", instClass.getSimpleName(), t);

1032

1033

// Return default instances for known types

1034

if (instClass == Person.class) {

1035

return new Person("Unknown", "", 0, null);

1036

}

1037

1038

// Re-throw for unknown types

1039

return NOT_HANDLED;

1040

}

1041

1042

@Override

1043

public Object handleMissingInstantiator(DeserializationContext ctxt, Class<?> instClass, ValueInstantiator valueInst, JsonParser p, String msg) throws IOException {

1044

logger.warn("Missing instantiator for {}: {}", instClass.getSimpleName(), msg);

1045

1046

// Provide default constructor logic

1047

try {

1048

return instClass.getDeclaredConstructor().newInstance();

1049

} catch (Exception e) {

1050

return NOT_HANDLED;

1051

}

1052

}

1053

}

1054

1055

// Usage

1056

ObjectMapper mapper = new ObjectMapper();

1057

mapper.addHandler(new LoggingDeserializationProblemHandler());

1058

1059

// Configure to be lenient with unknown properties

1060

mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

1061

```

1062

1063

### Deserialization Features Configuration

1064

1065

```java

1066

ObjectMapper mapper = new ObjectMapper();

1067

1068

// Configure deserialization features

1069

mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

1070

mapper.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);

1071

mapper.configure(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS, true);

1072

mapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, false);

1073

1074

// Multiple features at once

1075

mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,

1076

DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS);

1077

1078

mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES,

1079

DeserializationFeature.FAIL_ON_INVALID_SUBTYPE);

1080

1081

// Check feature status

1082

boolean lenient = !mapper.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

1083

boolean bigDecimals = mapper.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);

1084

1085

// Configure through ObjectReader

1086

ObjectReader reader = mapper.reader()

1087

.without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)

1088

.with(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);

1089

1090

Person person = reader.readValue(jsonWithUnknownProps, Person.class);

1091

```

1092

1093

## Types

1094

1095

```java { .api }

1096

// Deserializer interfaces

1097

public interface ContextualDeserializer {

1098

JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException;

1099

}

1100

1101

public interface ResolvableDeserializer {

1102

void resolve(DeserializationContext ctxt) throws JsonMappingException;

1103

}

1104

1105

// Key deserializer base

1106

public abstract class KeyDeserializer {

1107

public abstract Object deserializeKey(String key, DeserializationContext ctxt) throws IOException;

1108

1109

public static abstract class None extends KeyDeserializer { }

1110

}

1111

1112

// Null value provider interface

1113

public interface NullValueProvider {

1114

Object getNullValue(DeserializationContext ctxt) throws JsonMappingException;

1115

Object getAbsentValue(DeserializationContext ctxt) throws JsonMappingException;

1116

AccessPattern getNullAccessPattern();

1117

}

1118

1119

// Value instantiator for object creation

1120

public abstract class ValueInstantiator {

1121

// Default instantiation

1122

public boolean canCreateUsingDefault();

1123

public Object createUsingDefault(DeserializationContext ctxt) throws IOException;

1124

1125

// Delegate instantiation

1126

public boolean canCreateUsingDelegate();

1127

public Object createUsingDelegate(DeserializationContext ctxt, Object delegate) throws IOException;

1128

public JavaType getDelegateType(DeserializationConfig config);

1129

1130

// Array delegate instantiation

1131

public boolean canCreateUsingArrayDelegate();

1132

public Object createUsingArrayDelegate(DeserializationContext ctxt, Object delegate) throws IOException;

1133

public JavaType getArrayDelegateType(DeserializationConfig config);

1134

1135

// Scalar instantiation

1136

public boolean canCreateFromString();

1137

public Object createFromString(DeserializationContext ctxt, String value) throws IOException;

1138

public boolean canCreateFromInt();

1139

public Object createFromInt(DeserializationContext ctxt, int value) throws IOException;

1140

public boolean canCreateFromLong();

1141

public Object createFromLong(DeserializationContext ctxt, long value) throws IOException;

1142

public boolean canCreateFromDouble();

1143

public Object createFromDouble(DeserializationContext ctxt, double value) throws IOException;

1144

public boolean canCreateFromBoolean();

1145

public Object createFromBoolean(DeserializationContext ctxt, boolean value) throws IOException;

1146

1147

// Properties-based instantiation

1148

public boolean canCreateFromObjectWith();

1149

public Object createFromObjectWith(DeserializationContext ctxt, Object[] args) throws IOException;

1150

public SettableBeanProperty[] getFromObjectArguments(DeserializationConfig config);

1151

1152

// Metadata

1153

public String getValueTypeDesc();

1154

}

1155

1156

// Deserializer registration interface

1157

public interface Deserializers {

1158

JsonDeserializer<?> findBeanDeserializer(JavaType type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException;

1159

JsonDeserializer<?> findReferenceDeserializer(ReferenceType refType, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer contentTypeDeserializer, JsonDeserializer<?> contentDeserializer) throws JsonMappingException;

1160

JsonDeserializer<?> findArrayDeserializer(ArrayType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException;

1161

JsonDeserializer<?> findCollectionDeserializer(CollectionType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException;

1162

JsonDeserializer<?> findCollectionLikeDeserializer(CollectionLikeType type, DeserializationConfig config, BeanDescription beanDesc, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException;

1163

JsonDeserializer<?> findMapDeserializer(MapType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException;

1164

JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type, DeserializationConfig config, BeanDescription beanDesc, KeyDeserializer keyDeserializer, TypeDeserializer elementTypeDeserializer, JsonDeserializer<?> elementDeserializer) throws JsonMappingException;

1165

JsonDeserializer<?> findEnumDeserializer(Class<?> type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException;

1166

JsonDeserializer<?> findTreeNodeDeserializer(Class<? extends JsonNode> nodeType, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException;

1167

1168

public static abstract class Base implements Deserializers {

1169

// Default implementations returning null

1170

}

1171

}

1172

1173

// Bean deserializer modifier

1174

public abstract class BeanDeserializerModifier {

1175

public List<BeanPropertyDefinition> updateProperties(DeserializationConfig config, BeanDescription beanDesc, List<BeanPropertyDefinition> propDefs);

1176

public List<SettableBeanProperty> updateProperties(DeserializationConfig config, BeanDescription beanDesc, List<SettableBeanProperty> propDefs);

1177

public BeanDeserializerBuilder updateBuilder(DeserializationConfig config, BeanDescription beanDesc, BeanDeserializerBuilder builder);

1178

public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer);

1179

public JsonDeserializer<?> modifyArrayDeserializer(DeserializationConfig config, ArrayType valueType, BeanDescription beanDesc, JsonDeserializer<?> deserializer);

1180

public JsonDeserializer<?> modifyCollectionDeserializer(DeserializationConfig config, CollectionType type, BeanDescription beanDesc, JsonDeserializer<?> deserializer);

1181

public JsonDeserializer<?> modifyCollectionLikeDeserializer(DeserializationConfig config, CollectionLikeType type, BeanDescription beanDesc, JsonDeserializer<?> deserializer);

1182

public JsonDeserializer<?> modifyMapDeserializer(DeserializationConfig config, MapType type, BeanDescription beanDesc, JsonDeserializer<?> deserializer);

1183

public JsonDeserializer<?> modifyMapLikeDeserializer(DeserializationConfig config, MapLikeType type, BeanDescription beanDesc, JsonDeserializer<?> deserializer);

1184

public JsonDeserializer<?> modifyEnumDeserializer(DeserializationConfig config, JavaType type, BeanDescription beanDesc, JsonDeserializer<?> deserializer);

1185

public JsonDeserializer<?> modifyKeyDeserializer(DeserializationConfig config, JavaType type, JsonDeserializer<?> deserializer);

1186

}

1187

1188

// Problem handler for deserialization issues

1189

public abstract class DeserializationProblemHandler {

1190

public static final Object NOT_HANDLED = new Object();

1191

1192

public boolean handleUnknownProperty(DeserializationContext ctxt, JsonParser p, JsonDeserializer<?> deserializer, Object beanOrClass, String propertyName) throws IOException;

1193

public Object handleInstantiationProblem(DeserializationContext ctxt, Class<?> instClass, Object argument, Throwable t) throws IOException;

1194

public Object handleMissingInstantiator(DeserializationContext ctxt, Class<?> instClass, ValueInstantiator valueInst, JsonParser p, String msg) throws IOException;

1195

public Object handleMissingTypeId(DeserializationContext ctxt, JavaType baseType, TypeIdResolver idResolver, String failureMsg) throws IOException;

1196

public JavaType handleUnknownTypeId(DeserializationContext ctxt, JavaType baseType, String subTypeId, TypeIdResolver idResolver, String failureMsg) throws IOException;

1197

public JavaType handleMissingTypeId(DeserializationContext ctxt, JavaType baseType, TypeIdResolver idResolver, String failureMsg) throws IOException;

1198

}

1199

```

1200

1201

<function_calls>

1202

<invoke name="TodoWrite">

1203

<parameter name="todos">[{"content": "Create entry-point document (index.md) with overview and key API snippets", "status": "completed", "activeForm": "Creating entry-point document"}, {"content": "Create object-mapping.md sub-document covering ObjectMapper, ObjectReader, ObjectWriter", "status": "completed", "activeForm": "Creating object-mapping.md"}, {"content": "Create json-tree-model.md sub-document covering JsonNode hierarchy and tree manipulation", "status": "completed", "activeForm": "Creating json-tree-model.md"}, {"content": "Create type-system.md sub-document covering JavaType and type handling", "status": "completed", "activeForm": "Creating type-system.md"}, {"content": "Create serialization.md sub-document covering JsonSerializer and serialization framework", "status": "completed", "activeForm": "Creating serialization.md"}, {"content": "Create deserialization.md sub-document covering JsonDeserializer and deserialization framework", "status": "completed", "activeForm": "Creating deserialization.md"}, {"content": "Create configuration.md sub-document covering features, settings, and configuration", "status": "in_progress", "activeForm": "Creating configuration.md"}, {"content": "Create annotations.md sub-document covering Jackson databind annotations", "status": "pending", "activeForm": "Creating annotations.md"}, {"content": "Create modules.md sub-document covering Module system and extensibility", "status": "pending", "activeForm": "Creating modules.md"}, {"content": "Create advanced-features.md sub-document covering polymorphism, custom handlers, etc.", "status": "pending", "activeForm": "Creating advanced-features.md"}]