| to_json {SparkR} | R Documentation |
Converts a column containing a structType or array of structType into a Column
of JSON string. Resolving the Column can fail if an unsupported type is encountered.
to_json(x, ...) ## S4 method for signature 'Column' to_json(x, ...)
x |
Column containing the struct or array of the structs |
... |
additional named properties to control how it is converted, accepts the same options as the JSON data source. |
to_json since 2.2.0
Other normal_funcs: abs,
bitwiseNOT, coalesce,
column, expr,
from_json, greatest,
ifelse, isnan,
least, lit,
nanvl, negate,
randn, rand,
struct, when
## Not run:
##D # Converts a struct into a JSON object
##D df <- sql("SELECT named_struct('date', cast('2000-01-01' as date)) as d")
##D select(df, to_json(df$d, dateFormat = 'dd/MM/yyyy'))
##D
##D # Converts an array of structs into a JSON array
##D df <- sql("SELECT array(named_struct('name', 'Bob'), named_struct('name', 'Alice')) as people")
##D select(df, to_json(df$people))
## End(Not run)