/** * The method to be called by {@link ObjectMapper} and {@link ObjectWriter} * for serializing given value, using serializers that * this provider has access to (via caching and/or creating new serializers * as need be). */ public void serializeValue(JsonGenerator gen, Object value) throws IOException { _generator = gen; if (value == null) { _serializeNull(gen); return; } final Class<?> cls = value.getClass(); // true, since we do want to cache root-level typed serializers (ditto for null property) final JsonSerializer<Object> ser = findTypedValueSerializer(cls, true, null); PropertyName rootName = _config.getFullRootName(); if (rootName == null) { // not explicitly specified if (_config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE)) { _serialize(gen, value, ser, _config.findRootName(cls)); return; } } else if (!rootName.isEmpty()) { _serialize(gen, value, ser, rootName); return; } _serialize(gen, value, ser); }
JsonSerializer<Object> ser = findTypedValueSerializer(rootType, true, null); PropertyName rootName = _config.getFullRootName(); if (rootName == null) { // not explicitly specified
ser = findTypedValueSerializer(rootType, true, null);
JsonSerializer<Object> ser = prov.findTypedValueSerializer(newType, true, null);
/** * Method called to locate (root) serializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected final JsonSerializer<Object> _prefetchRootSerializer( SerializationConfig config, JavaType valueType) { if (valueType == null || !_config.isEnabled(SerializationFeature.EAGER_SERIALIZER_FETCH)) { return null; } try { return _serializerProvider(config).findTypedValueSerializer(valueType, true, null); } catch (JsonProcessingException e) { // need to swallow? return null; } }
Class<?> cls = value.getClass(); ser = findTypedValueSerializer(cls, true, null);
Class<?> cls = value.getClass(); ser = findTypedValueSerializer(cls, true, null);
final JsonSerializer<Object> ser = findTypedValueSerializer(cls, true, null);
final JsonSerializer<Object> ser = findTypedValueSerializer(cls, true, null);
ser = findTypedValueSerializer(rootType, true, null);
JsonSerializer<Object> ser = findTypedValueSerializer(rootType, true, null);
ser = findTypedValueSerializer(rootType, true, null);
final JsonSerializer<Object> ser = findTypedValueSerializer(cls, true, null);
/** * Method called to locate (root) serializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected Prefetch _prefetchRootSerializer(SerializationConfig config, JavaType valueType) { if (valueType != null && _config.isEnabled(SerializationFeature.EAGER_SERIALIZER_FETCH)) { /* 17-Dec-2014, tatu: Need to be bit careful here; TypeSerializers are NOT cached, * so although it'd seem like a good idea to look for those first, and avoid * serializer for polymorphic types, it is actually more efficient to do the * reverse here. */ try { JsonSerializer<Object> ser = _serializerProvider(config).findTypedValueSerializer(valueType, true, null); // Important: for polymorphic types, "unwrap"... if (ser instanceof TypeWrappedSerializer) { return Prefetch.construct(valueType, ((TypeWrappedSerializer) ser).typeSerializer()); } return Prefetch.construct(valueType, ser); } catch (JsonProcessingException e) { // need to swallow? ; } } return Prefetch.empty; }
/** * Method called to locate (root) serializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected Prefetch _prefetchRootSerializer(SerializationConfig config, JavaType valueType) { if (valueType != null && _config.isEnabled(SerializationFeature.EAGER_SERIALIZER_FETCH)) { /* 17-Dec-2014, tatu: Need to be bit careful here; TypeSerializers are NOT cached, * so although it'd seem like a good idea to look for those first, and avoid * serializer for polymorphic types, it is actually more efficient to do the * reverse here. */ try { JsonSerializer<Object> ser = _serializerProvider(config).findTypedValueSerializer(valueType, true, null); // Important: for polymorphic types, "unwrap"... if (ser instanceof TypeWrappedSerializer) { return Prefetch.construct(valueType, ((TypeWrappedSerializer) ser).typeSerializer()); } return Prefetch.construct(valueType, ser); } catch (JsonProcessingException e) { // need to swallow? ; } } return Prefetch.empty; }
ser = findTypedValueSerializer(rootType, true, null);
/** * The method to be called by {@link ObjectMapper} and {@link ObjectWriter} * for serializing given value, using serializers that * this provider has access to (via caching and/or creating new serializers * as need be). */ public void serializeValue(JsonGenerator gen, Object value) throws IOException { _generator = gen; if (value == null) { _serializeNull(gen); return; } final Class<?> cls = value.getClass(); // true, since we do want to cache root-level typed serializers (ditto for null property) final JsonSerializer<Object> ser = findTypedValueSerializer(cls, true, null); PropertyName rootName = _config.getFullRootName(); if (rootName == null) { // not explicitly specified if (_config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE)) { _serialize(gen, value, ser, _config.findRootName(cls)); return; } } else if (!rootName.isEmpty()) { _serialize(gen, value, ser, rootName); return; } _serialize(gen, value, ser); }
JsonSerializer<Object> ser = findTypedValueSerializer(rootType, true, null); PropertyName rootName = _config.getFullRootName(); if (rootName == null) { // not explicitly specified
JsonSerializer<Object> ser = prov.findTypedValueSerializer(newType, true, null);
JsonSerializer<Object> ser = prov.findTypedValueSerializer(newType, true, null);