@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { Boolean unwrapSingle = findFormatFeature(ctxt, property, _valueClass, JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); NullValueProvider nuller = null; Nulls nullStyle = findContentNullStyle(ctxt, property); if (nullStyle == Nulls.SKIP) { nuller = NullsConstantProvider.skipper(); } else if (nullStyle == Nulls.FAIL) { if (property == null) { nuller = NullsFailProvider.constructForRootValue(ctxt.constructType(_valueClass)); } else { nuller = NullsFailProvider.constructForProperty(property); } } if ((unwrapSingle == _unwrapSingle) && (nuller == _nuller)) { return this; } return withResolved(nuller, unwrapSingle); }
@SuppressWarnings("unchecked") protected T handleNonArray(JsonParser p, DeserializationContext ctxt) throws IOException { // Empty String can become null... if (p.hasToken(JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { if (p.getText().length() == 0) { return null; } } boolean canWrap = (_unwrapSingle == Boolean.TRUE) || ((_unwrapSingle == null) && ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)); if (canWrap) { return handleSingleElementUnwrapped(p, ctxt); } return (T) ctxt.handleUnexpectedToken(_valueClass, p); }
@Override public T deserialize(JsonParser p, DeserializationContext ctxt, T existing) throws IOException { T newValue = deserialize(p, ctxt); if (existing == null) { return newValue; } int len = Array.getLength(existing); if (len == 0) { return newValue; } return _concat(existing, newValue); }
Class<?> raw = elemType.getRawClass(); if (elemType.isPrimitive()) { return PrimitiveArrayDeserializers.forType(raw);
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { Boolean unwrapSingle = findFormatFeature(ctxt, property, _valueClass, JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); if (unwrapSingle == _unwrapSingle) { return this; } return withResolved(unwrapSingle); }
@Override // since 2.9 public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException { Object empty = _emptyValue; if (empty == null) { _emptyValue = empty = _constructEmpty(); } return empty; }
protected PrimitiveArrayDeserializers() { _allDeserializers = new HashMap<JavaType,JsonDeserializer<Object>>(); // note: we'll use component type as key, not array type add(boolean.class, new BooleanDeser()); /* ByteDeser is bit special, as it has 2 separate modes of operation; * one for String input (-> base64 input), the other for * numeric input */ add(byte.class, new ByteDeser()); add(short.class, new ShortDeser()); add(int.class, new IntDeser()); add(long.class, new LongDeser()); add(float.class, new FloatDeser()); add(double.class, new DoubleDeser()); add(String.class, new StringDeser()); /* also: char[] is most likely only used with Strings; doesn't * seem to make sense to transfer as numbers */ add(char.class, new CharDeser()); }
Class<?> raw = elemType.getRawClass(); if (elemType.isPrimitive()) { return PrimitiveArrayDeserializers.forType(raw); } else if (raw == String.class) { return StringArrayDeserializer.instance;
@Override // since 2.9 public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingException { Object empty = _emptyValue; if (empty == null) { _emptyValue = empty = _constructEmpty(); } return empty; }
protected PrimitiveArrayDeserializers() { _allDeserializers = new HashMap<JavaType,JsonDeserializer<Object>>(); // note: we'll use component type as key, not array type add(boolean.class, new BooleanDeser()); /* ByteDeser is bit special, as it has 2 separate modes of operation; * one for String input (-> base64 input), the other for * numeric input */ add(byte.class, new ByteDeser()); add(short.class, new ShortDeser()); add(int.class, new IntDeser()); add(long.class, new LongDeser()); add(float.class, new FloatDeser()); add(double.class, new DoubleDeser()); add(String.class, new StringDeser()); /* also: char[] is most likely only used with Strings; doesn't * seem to make sense to transfer as numbers */ add(char.class, new CharDeser()); }
@Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { Boolean unwrapSingle = findFormatFeature(ctxt, property, _valueClass, JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); NullValueProvider nuller = null; Nulls nullStyle = findContentNullStyle(ctxt, property); if (nullStyle == Nulls.SKIP) { nuller = NullsConstantProvider.skipper(); } else if (nullStyle == Nulls.FAIL) { if (property == null) { nuller = NullsFailProvider.constructForRootValue(ctxt.constructType(_valueClass)); } else { nuller = NullsFailProvider.constructForProperty(property); } } if ((unwrapSingle == _unwrapSingle) && (nuller == _nuller)) { return this; } return withResolved(nuller, unwrapSingle); }
Class<?> raw = elemType.getRawClass(); if (elemType.isPrimitive()) { return PrimitiveArrayDeserializers.forType(raw);
@Override public T deserialize(JsonParser p, DeserializationContext ctxt, T existing) throws IOException { T newValue = deserialize(p, ctxt); if (existing == null) { return newValue; } int len = Array.getLength(existing); if (len == 0) { return newValue; } return _concat(existing, newValue); }
@SuppressWarnings("unchecked") protected T handleNonArray(JsonParser p, DeserializationContext ctxt) throws IOException { // [JACKSON-620] Empty String can become null... if (p.hasToken(JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { if (p.getText().length() == 0) { return null; } } boolean canWrap = (_unwrapSingle == Boolean.TRUE) || ((_unwrapSingle == null) && ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)); if (canWrap) { return handleSingleElementUnwrapped(p, ctxt); } return (T) ctxt.handleUnexpectedToken(_valueClass, p); }
Class<?> raw = elemType.getRawClass(); if (elemType.isPrimitive()) { return PrimitiveArrayDeserializers.forType(raw); } else if (raw == String.class) { return StringArrayDeserializer.instance;
@SuppressWarnings("unchecked") protected T handleNonArray(JsonParser p, DeserializationContext ctxt) throws IOException { // Empty String can become null... if (p.hasToken(JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { if (p.getText().length() == 0) { return null; } } boolean canWrap = (_unwrapSingle == Boolean.TRUE) || ((_unwrapSingle == null) && ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)); if (canWrap) { return handleSingleElementUnwrapped(p, ctxt); } return (T) ctxt.handleUnexpectedToken(_valueClass, p); }
Class<?> raw = elemType.getRawClass(); if (elemType.isPrimitive()) { return PrimitiveArrayDeserializers.forType(raw); } else if (raw == String.class) { return StringArrayDeserializer.instance;