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

from_json(x, schema, ...)

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

Arguments

x

Column containing the JSON string.

schema

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

...

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

as.json.array

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

Note

from_json since 2.2.0

See Also

Other normal_funcs: abs, bitwiseNOT, coalesce, column, expr, greatest, ifelse, isnan, least, lit, nanvl, negate, randn, rand, struct, to_json, when

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.2 Index]