You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The jsonlite::toJSON(...) removes the names attribute from vectors. See why that is here: jeroen/jsonlite#76 We use this in quite a few algorithms. A temporary work around would be to add keep_vec_names=TRUE to the .toJSON function. Unfortunately they are going to drop this argument:
Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.
A better solution would be to not use named vectors but named lists:
# named vectorvec<- c("a"=1, "b"=2)
jsonlite::toJSON(vec)
# output: [1,2] # named listlis<-list("a"=1, "b"=2)
jsonlite::toJSON(lis)
# output: {"a":[1],"b":[2]}
Best solution is to covert your vectors before transport (as.list):
The
jsonlite::toJSON(...)
removes thenames
attribute from vectors. See why that is here: jeroen/jsonlite#76 We use this in quite a few algorithms. A temporary work around would be to addkeep_vec_names=TRUE
to the.toJSON
function. Unfortunately they are going to drop this argument:A better solution would be to not use named vectors but named lists:
Best solution is to covert your vectors before transport (
as.list
):The text was updated successfully, but these errors were encountered: