@Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { _treeDeserializer = ctxt.findRootValueDeserializer(ctxt.constructType(JsonNode.class)); }
/** * @since 2.6 */ protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt) throws JsonMappingException { JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE); if (deser == null) { // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE); if (deser == null) { // can this happen? ctxt.reportBadDefinition(JSON_NODE_TYPE, "Cannot find a deserializer for type "+JSON_NODE_TYPE); } _rootDeserializers.put(JSON_NODE_TYPE, deser); } return deser; }
/** * Method called to locate deserializer for the passed root-level value. */ protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt, JavaType valueType) throws JsonMappingException { // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(valueType); if (deser == null) { // can this happen? return ctxt.reportBadDefinition(valueType, "Cannot find a deserializer for type "+valueType); } _rootDeserializers.put(valueType, deser); return deser; }
/** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readValue(JsonParser p, JavaType type) throws IOException { JsonDeserializer<Object> deser = findRootValueDeserializer(type); if (deser == null) { reportBadDefinition(type, "Could not find JsonDeserializer for type "+type); } return (T) deser.deserialize(p, this); }
/** * Method called to locate deserializer for the passed root-level value. */ protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt) throws JsonMappingException { if (_rootDeserializer != null) { return _rootDeserializer; } // Sanity check: must have actual type... JavaType t = _valueType; if (t == null) { ctxt.reportBadDefinition((JavaType) null, "No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(t); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(t); if (deser == null) { // can this happen? ctxt.reportBadDefinition(t, "Cannot find a deserializer for type "+t); } _rootDeserializers.put(t, deser); return deser; }
/** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(JavaType valueType) { if ((valueType == null) || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null; } // already cached? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser == null) { try { // If not, need to resolve; for which we need a temporary context as well: DeserializationContext ctxt = createDeserializationContext(null); deser = ctxt.findRootValueDeserializer(valueType); if (deser != null) { _rootDeserializers.put(valueType, deser); } return deser; } catch (JsonProcessingException e) { // need to swallow? } } return deser; } }
subDeser = ctxt.findRootValueDeserializer(type);
@SuppressWarnings("unchecked") @Override public MetaData deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonDeserializer<Object> deserializer = ctxt.findRootValueDeserializer( ctxt.getTypeFactory().constructMapType(Map.class, String.class, Object.class)); return MetaData.from((Map) deserializer.deserialize(jp, ctxt, new HashMap<>())); } }
JsonDeserializer<?> deser = ctxt.findRootValueDeserializer(idType); builder.setObjectIdReader(ObjectIdReader.construct(idType, objectIdInfo.getPropertyName(), gen, deser, idProp, resolver));
idGen = ctxt.objectIdGeneratorInstance(accessor, objectIdInfo); JsonDeserializer<?> deser = ctxt.findRootValueDeserializer(idType); oir = ObjectIdReader.construct(idType, objectIdInfo.getPropertyName(), idGen, deser, idProp, resolver);
idGen = ctxt.objectIdGeneratorInstance(accessor, objectIdInfo); JsonDeserializer<?> deser = ctxt.findRootValueDeserializer(idType); ObjectIdReader oir = ObjectIdReader.construct(idType, objectIdInfo.getPropertyName(), idGen, deser, idProp, resolver);
@Override public List<Object> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { List<Object> result = new ArrayList<>(); JsonDeserializer<Object> deser = ctxt.findRootValueDeserializer(contentType); Object object; // links is an object, so we parse till we find its end. while (!JsonToken.END_OBJECT.equals(jp.nextToken())) { if (!JsonToken.FIELD_NAME.equals(jp.getCurrentToken())) { throw new JsonParseException(jp, "Expected relation name"); } if (JsonToken.START_ARRAY.equals(jp.nextToken())) { while (!JsonToken.END_ARRAY.equals(jp.nextToken())) { object = deser.deserialize(jp, ctxt); result.add(object); } } else { object = deser.deserialize(jp, ctxt); result.add(object); } } return result; }
@Override public List<Object> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { List<Object> result = new ArrayList<>(); JsonDeserializer<Object> deser = ctxt.findRootValueDeserializer(contentType); Object object; // links is an object, so we parse till we find its end. while (!JsonToken.END_OBJECT.equals(jp.nextToken())) { if (!JsonToken.FIELD_NAME.equals(jp.getCurrentToken())) { throw new JsonParseException(jp, "Expected relation name"); } if (JsonToken.START_ARRAY.equals(jp.nextToken())) { while (!JsonToken.END_ARRAY.equals(jp.nextToken())) { object = deser.deserialize(jp, ctxt); result.add(object); } } else { object = deser.deserialize(jp, ctxt); result.add(object); } } return result; }
@Override public Optional<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { Object reference = ctxt.findRootValueDeserializer(_referenceType).deserialize(jp, ctxt); return Optional.of(reference); } }
/** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readValue(JsonParser p, JavaType type) throws IOException { JsonDeserializer<Object> deser = findRootValueDeserializer(type); if (deser == null) { } return (T) deser.deserialize(p, this); }
/** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readValue(JsonParser p, JavaType type) throws IOException { JsonDeserializer<Object> deser = findRootValueDeserializer(type); if (deser == null) { reportBadDefinition(type, "Could not find JsonDeserializer for type "+type); } return (T) deser.deserialize(p, this); }
/** * @since 2.4 */ @SuppressWarnings("unchecked") public <T> T readValue(JsonParser p, JavaType type) throws IOException { JsonDeserializer<Object> deser = findRootValueDeserializer(type); if (deser == null) { reportMappingException("Could not find JsonDeserializer for type %s", type); } return (T) deser.deserialize(p, this); }
@Override public ValueProvider<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonDeserializer dser = ctxt.findRootValueDeserializer( checkNotNull( innerType, "Invalid %s: innerType is null. Serialization error?", getClass())); Object o = dser.deserialize(jp, ctxt); return StaticValueProvider.of(o); } }
@Override public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonDeserializer<Object> deserializer = ctxt.findRootValueDeserializer(ctxt.constructType(byte[].class)); byte[] bytes = (byte[]) deserializer.deserialize(p, ctxt); return deserialize(bytes); }
@Override @SuppressWarnings("unchecked") public MessageParams deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonDeserializer<Object> mapDeser = ctxt.findRootValueDeserializer(MapType.construct( LinkedHashMap.class, SimpleType.construct(String.class), SimpleType.construct(Object.class))); Map<String, Object> m = (Map<String, Object>) mapDeser.deserialize(jp, ctxt); return new MessageParams(ImmutableMap.copyOf(m)); } }