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.
## S4 method for signature 'Column' to_json(x, ...) 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: Column-class
,
column
, column
,
column
,
column,character-method
,
column,jobj-method
; abs
,
abs,Column-method
;
bitwiseNOT
, bitwiseNOT
,
bitwiseNOT,Column-method
;
coalesce
, coalesce
,
coalesce
,
coalesce,Column-method
,
coalesce,SparkDataFrame-method
;
expr
, expr
,
expr,character-method
;
from_json
, from_json
,
from_json,Column,structType-method
;
greatest
, greatest
,
greatest,Column-method
;
ifelse
, ifelse,Column-method
;
is.nan
, is.nan,Column-method
,
isnan
, isnan
,
isnan,Column-method
; least
,
least
, least,Column-method
;
lit
, lit
,
lit,ANY-method
; nanvl
,
nanvl
, nanvl,Column-method
;
negate
, negate
,
negate,Column-method
; randn
,
randn
, randn
,
randn,missing-method
,
randn,numeric-method
; rand
,
rand
, rand
,
rand,missing-method
,
rand,numeric-method
; struct
,
struct
,
struct,characterOrColumn-method
;
when
, when
,
when,Column-method
## 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)