/** * Convert this RAML object to Yaml. * * @return Yaml string. * @throws IOException If something goes wrong. */ public String toYaml() throws IOException { YAMLMapper mapper = new YAMLMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, false); mapper.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true); return "#%RAML 1.0\n" + mapper.writer().withDefaultPrettyPrinter().writeValueAsString(this); }
public static <T> String toYamlString(T instance) { ObjectMapper mapper = new YAMLMapper() .disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID) .setSerializationInclusion(JsonInclude.Include.NON_EMPTY); try { return mapper.writeValueAsString(instance); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
private static void configPropertyInclusion() { mapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION); yamlMapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION); propsMapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION); csvMapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION); xmlMapper.setSerializationInclusion(DEFAULT_PROPERTY_INCLUSION); }
/** * Convert this RAML object to Yaml. * * @return Yaml string. * @throws IOException If something goes wrong. */ public String toYaml() throws IOException { YAMLMapper mapper = new YAMLMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, false); mapper.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true); return "#%RAML 1.0\n" + mapper.writer().withDefaultPrettyPrinter().writeValueAsString(this); }