/** * Streamlined version that is only used when no "special" * features are enabled. */ private final Object vanillaDeserialize(JsonParser p, DeserializationContext ctxt, JsonToken t) throws IOException { Object bean = _valueInstantiator.createUsingDefault(ctxt); for (; p.getCurrentToken() == JsonToken.FIELD_NAME; p.nextToken()) { String propName = p.getCurrentName(); // Skip field name: p.nextToken(); SettableBeanProperty prop = _beanProperties.find(propName); if (prop != null) { // normal case try { bean = prop.deserializeSetAndReturn(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, propName, ctxt); } } else { handleUnknownVanilla(p, ctxt, bean, propName); } } return bean; }
return _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(p, ctxt)); boolean hasStringCreator = _valueInstantiator.canCreateFromString(); boolean hasDefaultCtor = _valueInstantiator.canCreateUsingDefault(); return ctxt.handleMissingInstantiator(handledType(), getValueInstantiator(), p, "Throwable needs a default contructor, a single-String-arg constructor; or explicit @JsonCreator"); int pendingIx = 0; prop.deserializeAndSet(p, ctxt, throwable); continue; int len = _beanProperties.size(); pending = new Object[len + len]; if (isMessage) { if (hasStringCreator) { throwable = _valueInstantiator.createFromString(ctxt, p.getValueAsString()); prop.set(throwable, pending[i+1]); throwable = _valueInstantiator.createFromString(ctxt, null); } else { throwable = _valueInstantiator.createUsingDefault(ctxt);
if (_valueInstantiator.canCreateFromObjectWith()) { creatorProps = _valueInstantiator.getFromObjectArguments(ctxt.getConfig()); if (!prop.hasValueDeserializer()) { _replaceProperty(_beanProperties, creatorProps, prop, newProp); deser = ctxt.handlePrimaryContextualization(deser, prop, prop.getType()); prop = _resolveManagedReferenceProperty(ctxt, prop); JsonDeserializer<Object> unwrapping = orig.unwrappingDeserializer(xform); _beanProperties.remove(prop); continue; _beanProperties.remove(prop); continue; if (_valueInstantiator.canCreateUsingDelegate()) { JavaType delegateType = _valueInstantiator.getDelegateType(ctxt.getConfig()); _valueInstantiator.getDelegateCreator()); if (_valueInstantiator.canCreateUsingArrayDelegate()) { JavaType delegateType = _valueInstantiator.getArrayDelegateType(ctxt.getConfig()); _valueInstantiator.getArrayDelegateCreator());
/** * Method that will return true if any of <code>canCreateXxx</code> method * returns true: that is, if there is any way that an instance could * be created. */ public boolean canInstantiate() { return canCreateUsingDefault() || canCreateUsingDelegate() || canCreateUsingArrayDelegate() || canCreateFromObjectWith() || canCreateFromString() || canCreateFromInt() || canCreateFromLong() || canCreateFromDouble() || canCreateFromBoolean(); }
@SuppressWarnings("unchecked") @Override public Collection<String> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { if (_delegateDeserializer != null) { return (Collection<String>) _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(p, ctxt)); } final Collection<String> result = (Collection<String>) _valueInstantiator.createUsingDefault(ctxt); return deserialize(p, ctxt, result); }
/** * Method called to deserialize POJO value from a JSON boolean value (true, false) */ public Object deserializeFromBoolean(JsonParser p, DeserializationContext ctxt) throws IOException { JsonDeserializer<Object> delegateDeser = _delegateDeserializer(); if (delegateDeser != null) { if (!_valueInstantiator.canCreateFromBoolean()) { Object bean = _valueInstantiator.createUsingDelegate(ctxt, delegateDeser.deserialize(p, ctxt)); if (_injectables != null) { injectValues(ctxt, bean); } return bean; } } boolean value = (p.getCurrentToken() == JsonToken.VALUE_TRUE); return _valueInstantiator.createFromBoolean(ctxt, value); }
@Override public EnumMap<?,?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { if (_propertyBasedCreator != null) { return _deserializeUsingProperties(p, ctxt); } if (_delegateDeserializer != null) { return (EnumMap<?,?>) _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(p, ctxt)); } // Ok: must point to START_OBJECT JsonToken t = p.getCurrentToken(); if ((t != JsonToken.START_OBJECT) && (t != JsonToken.FIELD_NAME) && (t != JsonToken.END_OBJECT)) { // (empty) String may be ok however; or single-String-arg ctor if (t == JsonToken.VALUE_STRING) { return (EnumMap<?,?>) _valueInstantiator.createFromString(ctxt, p.getText()); } // slightly redundant (since String was passed above), but also handles empty array case: return _deserializeFromEmpty(p, ctxt); } EnumMap result = constructMap(ctxt); return deserialize(p, ctxt, result); }
return _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(p, ctxt)); Object bean = _valueInstantiator.createUsingDefault(ctxt); final Class<?> activeView = _needViewProcesing ? ctxt.getActiveView() : null; for (; p.getCurrentToken() == JsonToken.FIELD_NAME; p.nextToken()) { String propName = p.getCurrentName(); p.nextToken(); SettableBeanProperty prop = _beanProperties.find(propName); if (prop != null) { // normal case if (activeView != null && !prop.visibleInView(activeView)) { p.skipChildren(); continue; bean = prop.deserializeSetAndReturn(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, propName, ctxt);
public Object deserializeFromString(JsonParser p, DeserializationContext ctxt) throws IOException { // First things first: id Object Id is used, most likely that's it if (_objectIdReader != null) { return deserializeFromObjectId(p, ctxt); } // Bit complicated if we have delegating creator; may need to use it, // or might not... JsonDeserializer<Object> delegateDeser = _delegateDeserializer(); if (delegateDeser != null) { if (!_valueInstantiator.canCreateFromString()) { Object bean = _valueInstantiator.createUsingDelegate(ctxt, delegateDeser.deserialize(p, ctxt)); if (_injectables != null) { injectValues(ctxt, bean); } return bean; } } return _valueInstantiator.createFromString(ctxt, p.getText()); }
return _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(p, ctxt)); final Object bean = _valueInstantiator.createUsingDefault(ctxt); p.setCurrentValue(bean); final Class<?> activeView = _needViewProcesing ? ctxt.getActiveView() : null; String propName = p.hasTokenId(JsonTokenId.ID_FIELD_NAME) ? p.getCurrentName() : null; for (; propName != null; propName = p.nextFieldName()) { p.nextToken(); SettableBeanProperty prop = _beanProperties.find(propName); if (prop != null) { // normal case if ((activeView != null) && !prop.visibleInView(activeView)) { p.skipChildren(); continue; prop.deserializeAndSet(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, propName, ctxt);
/** * Streamlined version that is only used when no "special" * features are enabled. */ private final Object vanillaDeserialize(JsonParser jp, DeserializationContext ctxt, JsonToken t) throws IOException, JsonProcessingException { final Object bean = _valueInstantiator.createUsingDefault(ctxt); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { String propName = jp.getCurrentName(); // Skip field name: jp.nextToken(); SettableBeanProperty prop = _beanProperties.find(propName); if (prop != null) { // normal case try { prop.deserializeAndSet(jp, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, propName, ctxt); } } else { _vanillaDeserializeHandleUnknown(jp, ctxt, bean, propName); } } return bean; }
/** * Streamlined version that is only used when no "special" * features are enabled. */ private final Object vanillaDeserialize(JsonParser p, DeserializationContext ctxt, JsonToken t) throws IOException { final Object bean = _valueInstantiator.createUsingDefault(ctxt); // [databind#631]: Assign current value, to be accessible by custom serializers p.setCurrentValue(bean); if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) { String propName = p.getCurrentName(); do { p.nextToken(); SettableBeanProperty prop = _beanProperties.find(propName); if (prop != null) { // normal case try { prop.deserializeAndSet(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, propName, ctxt); } continue; } handleUnknownVanilla(p, ctxt, bean, propName); } while ((propName = p.nextFieldName()) != null); } return bean; }
if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) { String propertyName = p.getCurrentName(); do { p.nextToken(); SettableBeanProperty property = _beanProperties.find(propertyName); Object id = property.deserialize(p, ctxt); ReadableObjectId objectId = ctxt.findObjectId(id, _objectIdReader.generator, _objectIdReader.resolver); bean = _valueInstantiator.createUsingDefault(ctxt); property.set(bean, id); bean = _valueInstantiator.createUsingDefault(ctxt); p.setCurrentValue(bean); property.deserializeAndSet(p, ctxt, bean); } while ((propertyName = p.nextFieldName()) != null);
if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME) && _objectIdReader.isValidReferencePropertyName(p.getCurrentName(), p)) { return deserializeFromObjectId(p, ctxt); final Object bean = _valueInstantiator.createUsingDefault(ctxt); p.setCurrentValue(bean); if (p.canReadObjectId()) { Object id = p.getObjectId(); Class<?> view = ctxt.getActiveView(); if (view != null) { return deserializeWithView(p, ctxt, bean, view); do { p.nextToken(); SettableBeanProperty prop = _beanProperties.find(propName); if (prop != null) { // normal case try { prop.deserializeAndSet(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, propName, ctxt);
if (!p.isExpectedStartArrayToken()) { return _deserializeFromNonArray(p, ctxt); return _deserializeNonVanilla(p, ctxt); final Object bean = _valueInstantiator.createUsingDefault(ctxt); p.setCurrentValue(bean); final int propCount = props.length; while (true) { if (p.nextToken() == JsonToken.END_ARRAY) { return bean; if (prop != null) { // normal case try { prop.deserializeAndSet(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, prop.getName(), ctxt); if (!_ignoreAllUnknown && ctxt.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) { ctxt.reportWrongTokenException(this, JsonToken.END_ARRAY, "Unexpected JSON values; expected at most %d properties (in JSON Array)", propCount);
if (!p.isExpectedStartArrayToken()) { return finishBuild(ctxt, _deserializeFromNonArray(p, ctxt)); return finishBuild(ctxt, _deserializeNonVanilla(p, ctxt)); Object builder = _valueInstantiator.createUsingDefault(ctxt); final SettableBeanProperty[] props = _orderedProperties; int i = 0; final int propCount = props.length; while (true) { if (p.nextToken() == JsonToken.END_ARRAY) { return finishBuild(ctxt, builder); if (prop != null) { // normal case try { builder = prop.deserializeSetAndReturn(p, ctxt, builder); } catch (Exception e) { wrapAndThrow(e, builder, prop.getName(), ctxt); p.skipChildren(); if (!_ignoreAllUnknown && ctxt.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) { ctxt.reportInputMismatch(handledType(), "Unexpected JSON values; expected at most %d properties (in JSON Array)", propCount);
return deserializeFromObjectUsingNonDefault(p, ctxt); Object builder = _valueInstantiator.createUsingDefault(ctxt); if (_injectables != null) { injectValues(ctxt, builder); Class<?> activeView = _needViewProcesing ? ctxt.getActiveView() : null; final SettableBeanProperty[] props = _orderedProperties; int i = 0; final int propCount = props.length; while (true) { if (p.nextToken() == JsonToken.END_ARRAY) { return builder; p.skipChildren(); if (!_ignoreAllUnknown && ctxt.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) { ctxt.reportWrongTokenException(this, JsonToken.END_ARRAY, "Unexpected JSON value(s); expected at most %d properties (in JSON Array)", propCount); while (p.nextToken() != JsonToken.END_ARRAY) { p.skipChildren();
return deserializeFromObjectUsingNonDefault(p, ctxt); final Object bean = _valueInstantiator.createUsingDefault(ctxt); p.setCurrentValue(bean); if (_injectables != null) { injectValues(ctxt, bean); Class<?> activeView = _needViewProcesing ? ctxt.getActiveView() : null; final SettableBeanProperty[] props = _orderedProperties; int i = 0; if (p.nextToken() == JsonToken.END_ARRAY) { return bean; ++i; if (prop != null) { // normal case if (activeView == null || prop.visibleInView(activeView)) { try { prop.deserializeAndSet(p, ctxt, bean); } catch (Exception e) { wrapAndThrow(e, bean, prop.getName(), ctxt); p.skipChildren(); ctxt.reportWrongTokenException(this, JsonToken.END_ARRAY, "Unexpected JSON values; expected at most %d properties (in JSON Array)", propCount);
@SuppressWarnings("unchecked") @Override public Collection<Object> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { if (_delegateDeserializer != null) { return (Collection<Object>) _valueInstantiator.createUsingDelegate(ctxt, _delegateDeserializer.deserialize(p, ctxt)); } // Empty String may be ok; bit tricky to check, however, since // there is also possibility of "auto-wrapping" of single-element arrays. // Hence we only accept empty String here. if (p.hasToken(JsonToken.VALUE_STRING)) { String str = p.getText(); if (str.length() == 0) { return (Collection<Object>) _valueInstantiator.createFromString(ctxt, str); } } return deserialize(p, ctxt, createDefaultInstance(ctxt)); }
return deserializeFromObjectId(p, ctxt); final JsonDeserializer<Object> delegateDeser = _delegateDeserializer(); NumberType nt = p.getNumberType(); if (nt == NumberType.INT) { if (delegateDeser != null) { if (!_valueInstantiator.canCreateFromInt()) { Object bean = _valueInstantiator.createUsingDelegate(ctxt, delegateDeser.deserialize(p, ctxt)); if (_injectables != null) { injectValues(ctxt, bean); return _valueInstantiator.createFromInt(ctxt, p.getIntValue()); if (!_valueInstantiator.canCreateFromInt()) { Object bean = _valueInstantiator.createUsingDelegate(ctxt, delegateDeser.deserialize(p, ctxt)); if (_injectables != null) { injectValues(ctxt, bean); return _valueInstantiator.createFromLong(ctxt, p.getLongValue()); Object bean = _valueInstantiator.createUsingDelegate(ctxt, delegateDeser.deserialize(p, ctxt)); if (_injectables != null) { injectValues(ctxt, bean);