本文整理匯總了Java中com.fasterxml.jackson.databind.ObjectMapper.getSerializationConfig方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectMapper.getSerializationConfig方法的具體用法?Java ObjectMapper.getSerializationConfig怎麽用?Java ObjectMapper.getSerializationConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.databind.ObjectMapper
的用法示例。
在下文中一共展示了ObjectMapper.getSerializationConfig方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getName
import com.fasterxml.jackson.databind.ObjectMapper; //導入方法依賴的package包/類
protected Optional<String> getName(Method method) {
ObjectMapper objectMapper = context.getObjectMapper();
SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
String name = ClassUtils.getGetterFieldName(method);
Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations);
int paramsLength = method.getParameterAnnotations().length;
AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength];
for (int i = 0; i < paramsLength; i++) {
AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]);
paramAnnotations[i] = parameterAnnotationMap;
}
AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig);
AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations);
return Optional.of(serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name));
}
return Optional.empty();
}