1
Hello,
I am working on building a data frame in R from a JSON that I receive after doing a GET on a service, but I am getting an error because one of the return JSON values is null, it follows part of the code used:
id <- callback$data$id
uri <- callback$data$uri
name <- callback$data$name
email <- callback$data$email
status <- callback$data$status
data <- data.frame(id,
uri,
name,
email,
status)
data <- tibble::as_tibble(data)
Follow JSON of return:
“data”: { "id": 7658, "uri": "https://sampleuri.io/samples”, “name”: “A return example“, “email”: null, “status”: “ACTIVE”, }
Follows error:
Error in data.frame(id, Uri, name, email, status, : Arguments imply differing number of Rows: 1, 0
I tested by removing the email variable and the data frame is created correctly, someone could help me in a way to make R accept the null value of the email variable?
Thanks so much for your help.
Change to
NA
: maybesub('null', 'NA', callback$data$email)
. This is becauselength(NULL)
is equal to 0.– Rui Barradas
Hello @Ruibarradas Thanks so much for the tip, it worked :D
– Mário Dias