Doesn't like as.list, only fields and slots are converted, prepare a object to be conveted to YAML/JSON.

asList(object, ...)

# S4 method for ANY
asList(object, ...)

# S4 method for CWL
asList(object, ...)

# S4 method for SingleEnum
asList(object, ...)

# S4 method for SimpleList
asList(object, ...)

# S4 method for DSCList
asList(object, ...)

Arguments

object

object, could be S4/R5 object. For example, class CWL, SimpleList.

...

other parameters passed to as.yaml or toJSON.

Value

a list object or json or yaml file.

Examples

# 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
#> x: world #> 'y': #> a: hello #> b: 123.0 #>
b$show("JSON")
#> { #> "x": "world", #> "y": { #> "a": "hello", #> "b": 123 #> } #> } #>
b$show("YAML")
#> x: world #> 'y': #> a: hello #> b: 123.0 #>
# You can convert slots/fields into a list asList(a)
#> $a #> [1] "hello" #> #> $b #> [1] 123 #>
asList(b)
#> $x #> [x] "world" #> #> $y #> $y$a #> [x] "hello" #> #> $y$b #> [x] 123 #> #>
b$toList()
#> $x #> [x] "world" #> #> $y #> $y$a #> [x] "hello" #> #> $y$b #> [x] 123 #> #>
b$toYAML()
#> [1] "x: world\n'y':\n a: hello\n b: 123.0\n"
b$toJSON()
#> {"x":"world","y":{"a":"hello","b":123}}