此代碼Bean類型將輸出:(YAML)如何隱藏在snakeyaml
--- !! org.test.bean.Person
地址:4011第16大道小號
.. ...
無論如何都可以隱藏我的bean類型(org.test.bean.Person)! (更喜歡使用snakeyaml配置...我無法找到它..)
謝謝!!
public static void dumpYAML(){
Constructor constructor = new Constructor(Person.class);
TypeDescription personDescription = new TypeDescription(Person.class);
personDescription.putListPropertyType("phone", Tel.class);
constructor.addTypeDescription(personDescription);
Yaml yaml = new Yaml(constructor);
Person person = (Person) yaml.load(makeYAML());
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setCanonical(false); // display bean member attribute
options.setExplicitStart(true); // display --- start
yaml = new Yaml(options);
String output = yaml.dump(person);
System.out.println(output);
}