Skip to contents

Convert an rtemis S7 object to a named list suitable for jsonlite::toJSON(auto_unbox = TRUE). Used by the rtemislive backend to send structured results to the browser frontend without scraping R console output.

Usage

to_json(x, ...)

Arguments

x

rtemis S7 object.

...

Additional arguments passed to method.

Value

Named list. Pass through jsonlite::toJSON(auto_unbox = TRUE) for serialization.

Details

Each output list includes a .class field equal to the most specific S7 class name, allowing the frontend to dispatch to a class-specific renderer.

The default method walks the class's published properties (see prop_published()), recursing into S7-typed properties and passing through primitive properties as-is. A computed view or an R-only value is omitted: the first is recoverable from what is published, and the second has no wire form at all, so emitting either would put a value on the wire that no schema declares. Per-class methods override where the default isn't appropriate (e.g. where some props should be excluded for size or relevance reasons).

Author

EDG

Examples

to_json(check_data(iris))
#> $.class
#> [1] "CheckData"
#> 
#> $object_class
#> [1] "data.frame"
#> 
#> $name
#> [1] "iris"
#> 
#> $n_rows
#> [1] 150
#> 
#> $n_cols
#> [1] 5
#> 
#> $n_numeric
#> [1] 4
#> 
#> $n_integer
#> [1] 0
#> 
#> $n_character
#> [1] 0
#> 
#> $n_factor
#> [1] 1
#> 
#> $n_ordered
#> [1] 0
#> 
#> $n_date
#> [1] 0
#> 
#> $n_constant
#> [1] 0
#> 
#> $n_duplicates
#> [1] 1
#> 
#> $n_cols_anyna
#> [1] 0
#> 
#> $n_na
#> [1] 0
#> 
#> $classes_na
#> NULL
#> 
#> $na_feature_pct
#> NULL
#> 
#> $na_case_pct
#> NULL
#> 
#> $n_na_last_col
#> [1] 0
#>