本文整理汇总了Java中com.fasterxml.jackson.module.paramnames.ParameterNamesModule类的典型用法代码示例。如果您正苦于以下问题:Java ParameterNamesModule类的具体用法?Java ParameterNamesModule怎么用?Java ParameterNamesModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParameterNamesModule类属于com.fasterxml.jackson.module.paramnames包,在下文中一共展示了ParameterNamesModule类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IiifObjectMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
public IiifObjectMapper() {
this.checkJacksonVersion();
// Don't include null properties
this.setSerializationInclusion(Include.NON_NULL);
// Both are needed to add `@context` to the top-level object
this.disable(SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS);
this.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
// Some array fields are unwrapped during serialization if they have only one value
this.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
// Register the problem handler
this.addHandler(new ProblemHandler());
// Disable writing dates as timestamps
this.registerModule(new JavaTimeModule());
this.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
// Enable automatic detection of parameter names in @JsonCreators
this.registerModule(new ParameterNamesModule());
// Register the module
this.registerModule(new IiifModule());
}
示例2: createObjectMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
private static ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Jdk8Module());
mapper.registerModule(new JavaTimeModule());
mapper.registerModule(new ParameterNamesModule());
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
return mapper;
}
示例3: testSerialization
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
@Test
public void testSerialization() throws IOException {
final String json =
"{" +
"\"type\": \"tcp\"," +
"\"host\": \"i am a host\"," +
"\"port\": \"12345\"," +
"\"timeout\": \"5 minutes\"" +
"}";
final ObjectMapper mapper = Jackson.newObjectMapper();
mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
final Environment env = mock(Environment.class);
when(env.getObjectMapper()).thenReturn(mapper);
final InfluxDbTcpWriter.Factory factory = mapper.readValue(json, InfluxDbTcpWriter.Factory.class);
assertEquals("expected TCP host", "i am a host", factory.host());
assertEquals("expected TCP port", 12345, factory.port());
assertEquals("expected TCP timeout", Duration.minutes(5), factory.timeout());
}
示例4: setup
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
/**
* Register.
*/
public void setup() {
// Prepare Environment with VertxInject
Environment.create();
// Set default Json Mapper options
Json.mapper.setAnnotationIntrospector(new JacksonLombokAnnotationIntrospector())
.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY).setSerializationInclusion(JsonInclude.Include.NON_NULL)
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS)
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
//Safe register VertxJsonModule on Mapper
.registerModule(new Jdk8Module())
.registerModule(new JavaTimeModule())
.registerModule(new ParameterNamesModule())
.registerModule(new VertxJsonModule());
}
示例5: getObjectMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
public static ObjectMapper getObjectMapper() {
if (mapper != null) {
return mapper;
}
SimpleModule simpleLocalDateModule = new SimpleModule();
simpleLocalDateModule.addSerializer(LocalDate.class, new SimpleLocalDateSerializer());
simpleLocalDateModule.addDeserializer(LocalDate.class, new SimpleLocalDateDeserializer());
mapper = new ObjectMapper()
// adds JDK 8 Parameter Name access for cleaner JSON-to-Object mapping
.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES))
.registerModule(simpleLocalDateModule);
return mapper;
}
示例6: objectMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
public ObjectMapper objectMapper() {
return new ObjectMapper()
.registerModule(new Jdk8Module())
.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES))
.registerModule(new JavaTimeModule()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}
示例7: objectMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
@Bean
@Primary
public ObjectMapper objectMapper() {
return new ObjectMapper()
.registerModule(new Jdk8Module())
.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES))
.registerModule(new JavaTimeModule()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}
示例8: objectMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
public static ObjectMapper objectMapper() {
return new ObjectMapper()
.setPropertyNamingStrategy(SNAKE_CASE)
.enable(ACCEPT_SINGLE_VALUE_AS_ARRAY)
.registerModule(new JavaTimeModule())
.registerModule(new Jdk8Module())
.registerModule(new ParameterNamesModule())
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
示例9: robotInit
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
/**
* The method that runs when the robot is turned on. Initializes all subsystems from the map.
*/
public void robotInit() {
//Set up start time
Clock.setStartTime();
Clock.updateTime();
enabled = false;
//Yes this should be a print statement, it's useful to know that robotInit started.
System.out.println("Started robotInit.");
Yaml yaml = new Yaml();
try {
Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH+"ballbasaur_map.yml"));
YAMLMapper mapper = new YAMLMapper();
String fixed = mapper.writeValueAsString(normalized);
mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
robotMap = mapper.readValue(fixed, RobotMap.class);
} catch (IOException e) {
System.out.println("Config file is bad/nonexistent!");
e.printStackTrace();
}
//Read sensors
this.robotMap.getUpdater().run();
this.loggerNotifier = new Notifier(robotMap.getLogger());
this.driveSubsystem = robotMap.getDrive();
//Run the logger to write all the events that happened during initialization to a file.
robotMap.getLogger().run();
Clock.updateTime();
}
示例10: objectMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
@Bean
public ObjectMapper objectMapper() {
return new ObjectMapper()
.registerModule(new Jdk8Module())
.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES))
.registerModule(new JavaTimeModule()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
}
示例11: createDefaultObjectMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
private static ObjectMapper createDefaultObjectMapper() {
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
objectMapper.registerModules(new Jdk8Module(), new ParameterNamesModule(), new JavaTimeModule());
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
return objectMapper;
}
开发者ID:zalando-nakadi,项目名称:nakadi-producer-spring-boot-starter,代码行数:9,代码来源:MockNakadiPublishingClient.java
示例12: jacksonBuilder
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
protected Jackson2ObjectMapperBuilder jacksonBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.modules(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES), new JavaTimeModule(), new FriendlyIdModule());
builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
builder.simpleDateFormat("yyyy-MM-dd");
builder.indentOutput(true);
return builder;
}
示例13: buildObjectMapper
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
public ObjectMapper buildObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Jaxrs2TypesModule());
mapper.registerModule(new ParameterNamesModule());
mapper.configure(SerializationFeature.WRITE_DATES_WITH_ZONE_ID, true);
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
mapper.configure(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE, false);
mapper.registerModule(new JavaTimeModule());
return mapper;
}
示例14: robotInit
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
/**
* The method that runs when the robot is turned on. Initializes all subsystems from the map.
*/
public void robotInit() {
//Set up start time
Clock.setStartTime();
Clock.updateTime();
enabled = false;
//Yes this should be a print statement, it's useful to know that robotInit started.
System.out.println("Started robotInit.");
Yaml yaml = new Yaml();
try {
//Read the yaml file with SnakeYaml so we can use anchors and merge syntax.
Map<?, ?> normalized = (Map<?, ?>) yaml.load(new FileReader(RESOURCES_PATH + mapName));
YAMLMapper mapper = new YAMLMapper();
//Turn the Map read by SnakeYaml into a String so Jackson can read it.
String fixed = mapper.writeValueAsString(normalized);
//Use a parameter name module so we don't have to specify name for every field.
mapper.registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
//Add mix-ins
mapper.registerModule(new WPIModule());
//Deserialize the map into an object.
robotMap = mapper.readValue(fixed, RobotMap.class);
} catch (IOException e) {
//This is either the map file not being in the file system OR it being improperly formatted.
System.out.println("Config file is bad/nonexistent!");
e.printStackTrace();
}
//Read sensors
this.robotMap.getUpdater().run();
//Set fields from the map.
this.loggerNotifier = new Notifier(robotMap.getLogger());
//Run the logger to write all the events that happened during initialization to a file.
robotMap.getLogger().run();
Clock.updateTime();
}
示例15: createDefaultRetrofitBuilder
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; //导入依赖的package包/类
private static Retrofit.Builder createDefaultRetrofitBuilder() {
final ObjectMapper objectMapper = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
// Register ParameterNamesModule to read parameter name from lombok generated constructor.
.registerModule(new ParameterNamesModule())
// Register JSR-310(java.time.temporal.*) module and read number as millsec.
.registerModule(new JavaTimeModule())
.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
return new Retrofit.Builder()
.addConverterFactory(JacksonConverterFactory.create(objectMapper));
}