List of usage examples for com.fasterxml.jackson.databind PropertyNamingStrategy CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES
PropertyNamingStrategy CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES
To view the source code for com.fasterxml.jackson.databind PropertyNamingStrategy CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES.
Click Source Link
From source file:com.nextdoor.bender.ValidateSchema.java
public static void main(String[] args) throws ParseException, InterruptedException, IOException { /*//from w w w. j a v a 2 s. co m * Parse cli arguments */ Options options = new Options(); options.addOption(Option.builder().longOpt("schema").hasArg() .desc("Filename to output schema to. Default: schema.json").build()); options.addOption(Option.builder().longOpt("configs").hasArgs() .desc("List of config files to validate against schema.").build()); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); String schemaFilename = cmd.getOptionValue("schema", "schema.json"); String[] configFilenames = cmd.getOptionValues("configs"); /* * Validate config files against schema */ boolean hasFailures = false; for (String configFilename : configFilenames) { StringBuilder sb = new StringBuilder(); Files.lines(Paths.get(configFilename), StandardCharsets.UTF_8).forEach(p -> sb.append(p + "\n")); System.out.println("Attempting to validate " + configFilename); try { ObjectMapper mapper = BenderConfig.getObjectMapper(configFilename); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); BenderConfig.load(configFilename, sb.toString(), mapper, true); System.out.println("Valid"); BenderConfig config = BenderConfig.load(configFilename, sb.toString()); } catch (ConfigurationException e) { System.out.println("Invalid"); e.printStackTrace(); hasFailures = true; } } if (hasFailures) { System.exit(1); } }
From source file:com.memtrip.gear2nd.parser.Deserialization.java
private static YAMLMapper getYAMLMapper() { YAMLMapper yamlMapper = new YAMLMapper(); yamlMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); yamlMapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); return yamlMapper; }
From source file:com.wirelust.sonar.plugins.bitbucket.client.JacksonObjectMapper.java
public static JacksonObjectMapper get() { JacksonObjectMapper mapper = new JacksonObjectMapper(); mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); // Bitbucket uses underscores in their json names, our value objects use camel case mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); // Bitbucket will sometimes return an array and sometimes return a single object for most lists mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); // In the unit tests this is set to true because we want it to fail there // but in production we don't want it to fail so easily. mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); // When sending JSON to bitbucket we want to leave out null properties. mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return mapper; }
From source file:com.wirelust.sonar.plugins.bitbucket.jackson.JacksonObjectMapper.java
public static JacksonObjectMapper get() { // Jackson 2.0 JacksonObjectMapper mapper = new JacksonObjectMapper(); mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, false); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return mapper; }
From source file:com.fizzed.stork.launcher.ConfigurationFactory.java
static public ObjectMapper createObjectMapper() { // create json deserializer ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); return mapper; }
From source file:no.dusken.momus.mapper.HibernateAwareObjectMapper.java
public HibernateAwareObjectMapper() { // converts lastName to last_name and the other way setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); registerModule(new Hibernate4Module()); }
From source file:io.werval.modules.json.JSONPlugin.java
@Override public void onActivate(Application application) throws ActivationException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); json = new JacksonJSON(mapper); }
From source file:com.mattermost.service.jacksonconverter.JacksonConverterFactory.java
private JacksonConverterFactory(ObjectMapper mapper) { if (mapper == null) throw new NullPointerException("mapper == null"); this.mapper = mapper; this.mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); this.mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); }
From source file:org.wildfly.swarm.jaxrs.CustomJsonProvider.java
private ObjectMapper getObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); return mapper; }
From source file:monasca.log.api.resource.AbstractMonApiResourceTest.java
@Override protected void setupResources() throws Exception { addSingletons(new IllegalArgumentExceptionMapper(), new JsonProcessingExceptionMapper(), new JsonMappingExceptionManager(), new ConstraintViolationExceptionMapper(), new ThrowableExceptionMapper<Throwable>() { });//w ww . j a v a 2s. c o m objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); objectMapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); }