## define a S4 object
A <- setClass("A", slots = list(a = "character", b = "numeric"))
## define a reference object which extends 'CWL' class
B <- setRefClass("B", fields = list(x = "character", y = "A"), contains = "CWL")
## new instances
a <- A(a = "hello", b = 123)
b <- B(x = "world", y = a)
## show
b
b$show("JSON")
b$show("YAML")
## You can convert slots/fields into a list
asList(a)
asList(b)
b$toList()
##asYAML
asYAML(a)
asYAML(b)
b$toYAML()
##asJSON
asJSON(a)
asJSON(b)
b$toJSON()
Run the code above in your browser using DataLab