本文整理汇总了Java中com.fasterxml.jackson.core.Version类的典型用法代码示例。如果您正苦于以下问题:Java Version类的具体用法?Java Version怎么用?Java Version使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Version类属于com.fasterxml.jackson.core包,在下文中一共展示了Version类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configObjectMapper
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
@Autowired
public void configObjectMapper(ObjectMapper objectMapper) {
AggregationDeserializer deserializer = new AggregationDeserializer();
deserializer.register("sterms", TermsAggregation.class);
deserializer.register("histogram", HistogramAggregation.class);
deserializer.register("date_histogram", DateHistogramAggregation.class);
deserializer.register("avg", SingleValueMetricsAggregation.class);
deserializer.register("sum", SingleValueMetricsAggregation.class);
deserializer.register("max", SingleValueMetricsAggregation.class);
deserializer.register("min", SingleValueMetricsAggregation.class);
deserializer.register("cardinality", SingleValueMetricsAggregation.class);
deserializer.register("value_count", SingleValueMetricsAggregation.class);
SimpleModule module = new SimpleModule("AggregationDeserializer",
new Version(1, 0, 0, null, "eu.luminis.elastic", "aggregation-elastic"));
module.addDeserializer(Aggregation.class, deserializer);
module.addKeyDeserializer(String.class, new AggregationKeyDeserializer());
objectMapper.registerModule(module);
}
示例2: getAppStatusList
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
@JsonIgnore
public List<AppStatus> getAppStatusList() {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.addMixIn(AppStatus.class, AppStatusMixin.class);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
resolver.addMapping(AppInstanceStatus.class, AppInstanceStatusImpl.class);
module.setAbstractTypes(resolver);
mapper.registerModule(module);
TypeReference<List<AppStatus>> typeRef = new TypeReference<List<AppStatus>>() {
};
if (this.platformStatus != null) {
return mapper.readValue(this.platformStatus, typeRef);
}
return new ArrayList<AppStatus>();
}
catch (Exception e) {
throw new IllegalArgumentException("Could not parse Skipper Platfrom Status JSON:" + platformStatus, e);
}
}
示例3: createJacksonModule
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
/**
* Creates Crnk Jackson module with all required serializers.<br />
* Adds the {@link LinksInformationSerializer} if <code>serializeLinksAsObjects</code> is set to <code>true</code>.
*
* @param serializeLinksAsObjects flag which decides whether the {@link LinksInformationSerializer} should be added as
* additional serializer or not.
*
* @return {@link com.fasterxml.jackson.databind.Module} with custom serializers
*/
public static SimpleModule createJacksonModule(boolean serializeLinksAsObjects) {
SimpleModule simpleModule = new SimpleModule(JSON_API_JACKSON_MODULE_NAME,
new Version(1, 0, 0, null, null, null));
simpleModule.addSerializer(new ErrorDataSerializer());
simpleModule.addDeserializer(ErrorData.class, new ErrorDataDeserializer());
if (serializeLinksAsObjects) {
simpleModule.addSerializer(new LinksInformationSerializer());
}
return simpleModule;
}
示例4: getEditorOptions
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
private ObjectExpression getEditorOptions(HtmlEditorConfiguration config)
{
final String options = config.getEditorOptions();
if( options == null || options.trim().length() == 0 )
{
return null;
}
try
{
final ObjectMapper jsonMapper = objectMapperService.createObjectMapper(LenientMapperExtension.NAME);
final SimpleModule module = new SimpleModule("equella", new Version(1, 0, 0, null));
module.addDeserializer(ObjectExpression.class, new ObjectExpressionDeserialiser());
jsonMapper.registerModule(module);
final ObjectExpression obj = jsonMapper.readValue(options, ObjectExpression.class);
return obj; // NOSONAR (kept local variable for readability)
}
catch( IOException io )
{
// Invalid editor options. Should never have happened.
LOGGER.error("Invalid HTML editor options", io);
return null;
}
}
示例5: extendMapper
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
@Override
public void extendMapper(ObjectMapper mapper)
{
SimpleModule restModule = new SimpleModule("RestModule", new Version(1, 0, 0, null));
// TODO this probably should be somewhere else, but it can't be in
// com.tle.core.jackson
// as that would make it dependent on equella i18n
restModule.addSerializer(new I18NSerializer());
mapper.registerModule(restModule);
mapper.registerModule(new JavaTypesModule());
mapper.registerModule(new RestStringsModule());
mapper.setSerializationInclusion(Include.NON_NULL);
// dev mode!
if( DebugSettings.isDebuggingMode() )
{
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
}
mapper.setDateFormat(new ISO8061DateFormatWithTZ());
}
示例6: ZefiroModule
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
public ZefiroModule() {
super("ZefiroModule", new Version(majorVersion, minorVersion, patchLevel, null, "it.makeit.zefiro",
"jersey-module-zefiro"));
addSerializer(new ObjectTypeSerializer());
addSerializer(new DocumentSerializer());
addSerializer(new PropertySerializer());
addSerializer(new RelationshipSerializer());
// PropertyDefinition
addSerializer(new PropertyDefinitionSerializer());
addSerializer(new PropertyDecimalDefinitionSerializer());
addSerializer(new PropertyIntegerDefinitionSerializer());
addSerializer(new PropertyStringDefinitionSerializer());
addDeserializer(DocumentPropertyBean.class, new DocumentPropertyDeserializer());
}
示例7: JacksonObjectMapperConfig
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
public JacksonObjectMapperConfig() {
super();
this.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
//this.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false); 不增加,避免key值为null,而避免节点消失
this.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.configure(Feature.ALLOW_UNQUOTED_CONTROL_CHARS, true);
//this.setSerializationInclusion(Include.NON_EMPTY); //对象转字符串时,只转化非空字段 zjs 需要占位
//SimpleModule module = new SimpleModule();
SimpleModule module = new SimpleModule("HTML XSS Serializer",
new Version(1, 0, 0, "FINAL", "com.simbest", "ep-jsonmodule"));
module.addSerializer(new JsonHtmlXssSerializer(String.class));
module.addDeserializer(Date.class, new CustomJsonDateDeseralizer());
// Add more here ...
registerModule(module);
}
示例8: getDeserializersModule
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
private Module getDeserializersModule(GlobalEnvironment environment) {
return new Module() {
@Override
public String getModuleName() {
return "graphql-spqr-deserializers";
}
@Override
public Version version() {
return Version.unknownVersion();
}
@Override
public void setupModule(SetupContext setupContext) {
setupContext.addDeserializers(new ConvertingDeserializers(environment));
}
};
}
示例9: newInstance
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
public static ObjectMapper newInstance() {
ObjectMapper mapper = new ObjectMapper();
//mapper.setSerializationInclusion(Inclusion.ALWAYS);
//mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false);
//mapper.getSerializerProvider().setNullValueSerializer(new NullValueSerializer());
/*Json反序列化时忽略多余的属性*/
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
SimpleModule module = new SimpleModule("JsonUtil", new Version(1, 0, 0, null));
//JavaObject to JSONString
module.addSerializer(new ToJsonLongSerializer());
module.addSerializer(new ToJsonSqlTimestampSerializer(DEFAULT_DATETIME_PATTERN));
module.addSerializer(new ToJsonDateSerializer(DEFAULT_DATETIME_PATTERN));
module.addSerializer(new ToJsonStringSerializer());
//JSONString to JavaObject
module.addDeserializer(Date.class, new CustomDateDeSerializer(Date.class,DEFAULT_FORMATS));
module.addDeserializer(Timestamp.class, (JsonDeserializer)new CustomSqlTimestampDeSerializer(Timestamp.class,DEFAULT_FORMATS));
module.addDeserializer(java.sql.Date.class,(JsonDeserializer)new CustomSqlDateDeSerializer(java.sql.Date.class, DEFAULT_FORMATS));
mapper.registerModule(module);
return mapper;
}
示例10: init
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
/**
* Private method to register the custom serializers and deserializers
*/
private void init() {
this.objectMapper = new ObjectMapper();
SimpleModule module = new SimpleModule("UserProfileService",
new Version(1, 0, 0, null, null, null));
module.addSerializer(UserProfile.class, new UserProfileSerializer());
module.addDeserializer(UserProfile.class, new UserProfileDeserializer());
module.addSerializer(Publication.class, new PublicationSerializer());
module.addDeserializer(Publication.class, new PublicationDeserializer());
module.addSerializer(Institution.class, new InstitutionSerializer());
module.addDeserializer(Institution.class, new InstitutionDeserializer());
objectMapper.registerModule(module);
}
示例11: createMapper
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
public static ObjectMapper createMapper() {
ObjectMapper mapper = new ObjectMapper();
// mapper.configure(AUTO_DETECT_GETTERS, false);
// mapper.configure(AUTO_DETECT_SETTERS, false);
// mapper.setDeserializationConfig(mapper.getDeserializationConfig().without(FAIL_ON_UNKNOWN_PROPERTIES));
// mapper.setSerializationConfig(mapper.getSerializationConfig().withSerializationInclusion(NON_DEFAULT));
// mapper.setVisibilityChecker(Std.defaultInstance().withFieldVisibility(ANY));
//
mapper.registerModule(new SimpleModule("jersey", new Version(1, 0, 0, null,null,null)) //
.addSerializer(_id, _idSerializer()) //
.addDeserializer(_id, _idDeserializer()));
mapper.registerModule(new JSR353Module());
mapper.registerModule(new JsonOrgModule());
return mapper;
}
示例12: getDefaultObjectMapper
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
/**
* Generates an {@link ObjectMapper} to serialize and deserialize JSON.
*
* @return The generated {@link ObjectMapper}.
*/
@Bean
public ObjectMapper getDefaultObjectMapper() {
final ObjectMapper mapper = new ObjectMapper();
final SimpleModule module = new SimpleModule("AnalysisSerializers", new Version(1, 0, 0, null, null, null));
// Add custom serializer & deserializer for AnalyzerType so that we can retrieve the correct singleton instance from spring
module.addSerializer(AnalyzerType.class, new AnalyzerTypeSerializer());
module.addDeserializer(AnalyzerType.class, new AnalyzerTypeDeserializer());
// Add custom serializer & deserializer for Analyzer so that we can save the parameter values used to create the analyzer
module.addSerializer(Analyzer.class, new AnalyzerSerializer());
module.addDeserializer(Analyzer.class, new AnalyzerDeserializer());
mapper.registerModule(module);
// Save type information in JSON when declared type is object so it is deserialized correctly
// Used because AnalyzerSpec has a map of string to object for saved parameter values
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT);
return mapper;
}
示例13: deserializeAppStatus
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
public static List<AppStatus> deserializeAppStatus(String platformStatus) {
try {
ObjectMapper mapper = new ObjectMapper();
mapper.addMixIn(AppStatus.class, AppStatusMixin.class);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
resolver.addMapping(AppInstanceStatus.class, AppInstanceStatusImpl.class);
module.setAbstractTypes(resolver);
mapper.registerModule(module);
TypeReference<List<AppStatus>> typeRef = new TypeReference<List<AppStatus>>() {
};
List<AppStatus> result = mapper.readValue(platformStatus, typeRef);
return result;
}
catch (Exception e) {
throw new IllegalArgumentException("Could not parse Skipper Platform Status JSON:" + platformStatus, e);
}
}
示例14: afterPropertiesSet
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
/**
* JAVADOC Method Level Comments
*
* @throws Exception JAVADOC.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void afterPropertiesSet()
throws Exception {
//Set up
SimpleModule module = new SimpleModule("user",
new Version(1, 0, 0, "User serializer/deserializer", null, null));
if (CollectionUtils.isNotEmpty(serialisers)) {
for (JsonSerializer<?> serialiser : serialisers) {
module.addSerializer(serialiser);
}
}
if (MapUtils.isNotEmpty(deserialisers)) {
for (Map.Entry<Class, JsonDeserializer> deserialiserEntry : deserialisers.entrySet()) {
module.addDeserializer(deserialiserEntry.getKey(), deserialiserEntry.getValue());
}
}
mapper.registerModule(module);
}
示例15: shouldUpdateInstanceWithCustomModule
import com.fasterxml.jackson.core.Version; //导入依赖的package包/类
@Test
public void shouldUpdateInstanceWithCustomModule() throws Exception {
// Given
final JsonSerializer<String> serialiser = mock(JsonSerializer.class);
TestCustomJsonModules1.modules = Collections.singletonList(
new SimpleModule("module1", new Version(1, 0, 0, null, null, null))
.addSerializer(String.class, serialiser)
);
System.setProperty(JSONSerialiser.JSON_SERIALISER_MODULES, TestCustomJsonModules1.class.getName());
// When
JSONSerialiser.update();
// Then
assertEquals(JSONSerialiser.class, JSONSerialiser.getInstance().getClass());
JSONSerialiser.serialise("test");
verify(serialiser).serialize(Mockito.eq("test"), Mockito.any(), Mockito.any());
}