I'm trying to figure out how to use nested data types with snakeyaml. I'm not able to get the inner class to display properly
class RawEdgeTypeSpec() {
@BeanProperty var edge_type: Int = -1
@BeanProperty var weighted: String = ""
}
class RawNodeTypeSpec {
@BeanProperty var node_type: Int = -1
@BeanProperty var edge_types: List[RawEdgeTypeSpec] = List()
}
val spec3 = new RawEdgeTypeSpec()
spec3.setEdge_type(2)
spec3.setWeighted("true")
val spec2 = new RawNodeTypeSpec()
spec2.setNode_type(2)
spec2.setEdge_types(List(spec3))
val output = new Yaml().dump(spec2)
This prints
edge_types: !!scala.collection.immutable.$colon$colon {}
node_type: 2
edge_types is not recognized and serialized properly
Similarly I'm having trouble deserializing yaml
SnakeYAML is a Java lib that doesn't know Scala, so you'll need to use java.util.List[RawEdgeTypeSpec]
for SnakeYAML to understand that this is a list.