I I 개체가 (내가 예를 들어, 인쇄가 콘솔 수있다.)자바 SnakeYaml - 참조 이름을 덤핑 방지
@Nonnull
private String outputObject(@Nonnull final ObjectToPrint packageSchedule) {
DumperOptions options = new DumperOptions();
options.setAllowReadOnlyProperties(true);
options.setPrettyFlow(true);
return new Yaml(new Constructor(), new JodaTimeRepresenter(), options).dump(ObjectToPrint);
}
모두 훌륭하지만 일부 yaml
표현으로 변환 얻기 위해 사용하는 다음과 같은 방법을 ObjectToPrint
구조체에 포함 된 개체 참조 이름과 실제 대상 콘텐츠가 아닌 것을 얻습니다.
!!com.blah.blah.ObjectToPrint
businessYears:
- businessYearMonths: 12
ppiYear: &id001 {
endDate: 30-06-2013,
endYear: 2013,
startDate: 01-07-2012,
startYear: 2012
}
ppiPeriod:
ppiYear: *id001
endDate: 27-03-2014
startDate: 21-06-2013
units: 24.000
number: 1
I는 ($id001
로 표시) 인쇄 ppiYear
개체가 동일한 개체 ppiPeriod
에서 사용하지만, 기준 이름이 존재하지 않는 오브젝트의 컨텐츠를 인쇄 상술하면 예에서 볼 수 있듯이. 구조체 내에서 yaml (ObjectToPrint
)로 변환하려는 객체를 사용할 때마다 객체 내용을 인쇄하는 방법. PS. 참조 이름 (&id001
)을 인쇄하지 않는 것이 좋지만 중요하지는 않습니다.
방금 ** ** (this.serializedNodes.contains (node)) { this.emitter.emit (새 AliasEvent (tAlias, null, null))} 주석을 달았습니다. } else {** serializeNode 메서드에서 ** anchorNode (node); ** serialize 메서드에서 **. 이로 인해 앵커 및 별칭이 생성되지 않았습니다. – Ajeesh
그게 OP가 요구 한 것입니다 :-). 일부 클래스에 대해서만 참조 검색을 해제하려면 myHook을 올바르게 구현해야합니다. –