/** * <p> * Serialize a Java object into a YAML string. Override the default root tag * with <code>Tag.MAP</code>. * </p> * <p> * This method is similar to <code>Yaml.dump(data)</code> except that the * root tag for the whole document is replaced with <code>Tag.MAP</code> tag * (implicit !!map). * </p> * <p> * Block Mapping is used as the collection style. See 10.2.2. Block Mappings * (http://yaml.org/spec/1.1/#id934537) * </p> * * @param data * Java object to be serialized to YAML * @return YAML String */ public String dumpAsMap(Object data) { return dumpAs(data, Tag.MAP, FlowStyle.BLOCK); }
@RequestMapping({ "/{label}/{name}-{profiles}.yml", "/{label}/{name}-{profiles}.yaml" }) public ResponseEntity<String> labelledYaml(@PathVariable String name, @PathVariable String profiles, @PathVariable String label, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws Exception { validateProfiles(profiles); Environment environment = labelled(name, profiles, label); Map<String, Object> result = convertToMap(environment); if (this.stripDocument && result.size() == 1 && result.keySet().iterator().next().equals("document")) { Object value = result.get("document"); if (value instanceof Collection) { return getSuccess(new Yaml().dumpAs(value, Tag.SEQ, FlowStyle.BLOCK)); } else { return getSuccess(new Yaml().dumpAs(value, Tag.STR, FlowStyle.BLOCK)); } } String yaml = new Yaml().dumpAsMap(result); if (resolvePlaceholders) { yaml = resolvePlaceholders(prepareEnvironment(environment), yaml); } return getSuccess(yaml); }
/** * <p> * Serialize a Java object into a YAML string. Override the default root tag * with <code>Tag.MAP</code>. * </p> * <p> * This method is similar to <code>Yaml.dump(data)</code> except that the * root tag for the whole document is replaced with <code>Tag.MAP</code> tag * (implicit !!map). * </p> * <p> * Block Mapping is used as the collection style. See 10.2.2. Block Mappings * (http://yaml.org/spec/1.1/#id934537) * </p> * * @param data * Java object to be serialized to YAML * @return YAML String */ public String dumpAsMap(Object data) { return dumpAs(data, Tag.MAP, FlowStyle.BLOCK); }
/** * <p> * Serialize a Java object into a YAML string. Override the default root tag * with <code>Tag.MAP</code>. * </p> * <p> * This method is similar to <code>Yaml.dump(data)</code> except that the * root tag for the whole document is replaced with <code>Tag.MAP</code> tag * (implicit !!map). * </p> * <p> * Block Mapping is used as the collection style. See 10.2.2. Block Mappings * (http://yaml.org/spec/1.1/#id934537) * </p> * * @param data * Java object to be serialized to YAML * @return YAML String */ public String dumpAsMap(Object data) { return dumpAs(data, Tag.MAP, FlowStyle.BLOCK); }
/** * <p> * Serialize a Java object into a YAML string. Override the default root tag * with <code>Tag.MAP</code>. * </p> * <p> * This method is similar to <code>Yaml.dump(data)</code> except that the * root tag for the whole document is replaced with <code>Tag.MAP</code> tag * (implicit !!map). * </p> * <p> * Block Mapping is used as the collection style. See 10.2.2. Block Mappings * (http://yaml.org/spec/1.1/#id934537) * </p> * * @param data * Java object to be serialized to YAML * @return YAML String */ public String dumpAsMap(Object data) { return dumpAs(data, Tag.MAP, FlowStyle.BLOCK); }
@Override public Object serialize(Object value) { return yaml().dumpAs(value, Tag.MAP, FlowStyle.BLOCK); }
@Override public Object serialize(Object value) { return yaml().dumpAs(value, Tag.MAP, FlowStyle.BLOCK); }
@Override public String createContaining(String filename, Object data) { String file; if (data instanceof Map || data instanceof byte[] || data instanceof String) { file = valuesFileCreateContaining(filename, data); } else { String yamlStr = yaml.dumpAs(data, null, DumperOptions.FlowStyle.BLOCK); file = createContaining(filename, yamlStr); } return file; }
String ser = yaml.dumpAs(object, Tag.MAP, null);