Learn R Programming

sevenbridges (version 1.2.4)

asList: Convert a object slots/fields to a list, json, yaml file

Description

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

Usage

asList(object, ...)
"asList"(object, ...)
"asList"(object, ...)
"asList"(object, ...)
"asList"(object, ...)
asYAML(object, ...)
"asYAML"(object, ...)
asJSON(object, ...)
"asJSON"(object, ...)
"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

Run this code
## 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