本文整理汇总了Java中com.fasterxml.jackson.databind.KeyDeserializer.deserializeKey方法的典型用法代码示例。如果您正苦于以下问题:Java KeyDeserializer.deserializeKey方法的具体用法?Java KeyDeserializer.deserializeKey怎么用?Java KeyDeserializer.deserializeKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.KeyDeserializer
的用法示例。
在下文中一共展示了KeyDeserializer.deserializeKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _deserializeEntries
import com.fasterxml.jackson.databind.KeyDeserializer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected T _deserializeEntries(JsonParser jp, DeserializationContext ctxt) throws IOException {
final KeyDeserializer keyDes = keyDeserializer;
final JsonDeserializer<?> valueDes = valueDeserializer;
final TypeDeserializer typeDeser = typeDeserializerForValue;
MapF<Object, Object> map = newInstance();
for (; jp.getCurrentToken() == JsonToken.FIELD_NAME; jp.nextToken()) {
String fieldName = jp.getCurrentName();
Object key = (keyDes == null) ? fieldName : keyDes.deserializeKey(fieldName, ctxt);
JsonToken t = jp.nextToken();
Object value;
if (t == JsonToken.VALUE_NULL) {
value = null;
} else if (typeDeser == null) {
value = valueDes.deserialize(jp, ctxt);
} else {
value = valueDes.deserializeWithType(jp, ctxt, typeDeser);
}
map.put(key, value);
}
return (T) map.unmodifiable();
}
示例2: _readAndBind
import com.fasterxml.jackson.databind.KeyDeserializer; //导入方法依赖的package包/类
protected final void _readAndBind(JsonParser paramJsonParser, DeserializationContext paramDeserializationContext, Map<Object, Object> paramMap)
{
JsonToken localJsonToken1 = paramJsonParser.getCurrentToken();
JsonToken localJsonToken2 = localJsonToken1;
if (localJsonToken1 == JsonToken.START_OBJECT)
localJsonToken2 = paramJsonParser.nextToken();
KeyDeserializer localKeyDeserializer = this._keyDeserializer;
JsonDeserializer localJsonDeserializer = this._valueDeserializer;
TypeDeserializer localTypeDeserializer = this._valueTypeDeserializer;
while (localJsonToken2 == JsonToken.FIELD_NAME)
{
String str = paramJsonParser.getCurrentName();
Object localObject1 = localKeyDeserializer.deserializeKey(str, paramDeserializationContext);
JsonToken localJsonToken3 = paramJsonParser.nextToken();
if ((this._ignorableProperties != null) && (this._ignorableProperties.contains(str)))
{
paramJsonParser.skipChildren();
}
else
{
Object localObject2;
if (localJsonToken3 == JsonToken.VALUE_NULL)
localObject2 = null;
else if (localTypeDeserializer == null)
localObject2 = localJsonDeserializer.deserialize(paramJsonParser, paramDeserializationContext);
else
localObject2 = localJsonDeserializer.deserializeWithType(paramJsonParser, paramDeserializationContext, localTypeDeserializer);
paramMap.put(localObject1, localObject2);
}
localJsonToken2 = paramJsonParser.nextToken();
}
}
示例3: findMapDeserializer
import com.fasterxml.jackson.databind.KeyDeserializer; //导入方法依赖的package包/类
@Override
public JsonDeserializer<?> findMapDeserializer(final MapType type, final DeserializationConfig config, BeanDescription beanDesc, final KeyDeserializer keyDeserializer,
final TypeDeserializer elementTypeDeserializer, final JsonDeserializer<?> elementDeserializer) throws JsonMappingException {
if (ImmutableMap.class.isAssignableFrom(type.getRawClass())) {
return new StdDeserializer<Object>(type) {
private static final long serialVersionUID = 1L;
@Override
public Object deserialize(JsonParser jp, DeserializationContext context) throws IOException {
JsonToken t = jp.getCurrentToken();
if (t == JsonToken.START_OBJECT) {
t = jp.nextToken();
}
if (t != JsonToken.FIELD_NAME && t != JsonToken.END_OBJECT) {
throw context.mappingException(type.getRawClass());
}
MutableMap<Object, Object> m = Maps.mutable.of();
for (; jp.getCurrentToken() == JsonToken.FIELD_NAME; jp.nextToken()) {
// Pointing to field name
String fieldName = jp.getCurrentName();
Object key = (keyDeserializer == null) ? fieldName : keyDeserializer.deserializeKey(fieldName, context);
t = jp.nextToken();
Object value;
if (t == JsonToken.VALUE_NULL) {
value = null;
}
else if (elementDeserializer == null) {
value = jp.readValueAs(type.getContentType().getRawClass());
}
else if (elementTypeDeserializer == null) {
value = elementDeserializer.deserialize(jp, context);
}
else {
value = elementDeserializer.deserializeWithType(jp, context, elementTypeDeserializer);
}
m.put(key, value);
}
return m.toImmutable();
}
};
}
return super.findMapDeserializer(type, config, beanDesc, keyDeserializer, elementTypeDeserializer, elementDeserializer);
}