from_json {SparkR}R Documentation

from_json

Description

Parses a column containing a JSON string into a Column of structType with the specified schema or array of structType if as.json.array is set to TRUE. If the string is unparseable, the Column will contains the value NA.

Usage

## S4 method for signature 'Column,structType'
from_json(x, schema, as.json.array = FALSE, ...)

from_json(x, schema, ...)

Arguments

x

Column containing the JSON string.

schema

a structType object to use as the schema to use when parsing the JSON string.

as.json.array

indicating if input string is JSON array of objects or a single object.

...

additional named properties to control how the json is parsed, accepts the same options as the JSON data source.

Note

from_json since 2.2.0

See Also

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; 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; to_json, to_json, to_json,Column-method; when, when, when,Column-method

Examples

## Not run: 
##D schema <- structType(structField("name", "string"),
##D select(df, from_json(df$value, schema, dateFormat = "dd/MM/yyyy"))
## End(Not run)

[Package SparkR version 2.2.0 Index]