i am facing the problem of JSON object naming in R.
df = list(`Choose to and fro flights` = data.frame(sec =c('15:31:36' ,'15:31:37'),label=c("Choose to and fro flights","Choose to and fro flights"),responseCode = c( 200, 200), Counting=c(9,1)),
`Details` = data.frame(sec = c("15:31:37" ,"15:31:37","15:31:38","15:31:39"),label = c("Details","Details","Details","Details"),responseCode = c("200","Non HTTP response code: org.apache.http.NoHttpResponseException","200","200"), Counting=c(2,2,5,1)))
i want the label name is same as the JSON object name here i am trying with following code but it's not give correct answer
toJSON(list(ResponseCode=lapply(seq_along(df), function(i) { list(R_C_seconds=df[[i]]$sec,R_C_labels=df[[i]]$label,R_C_responseCode=df[[i]]$responseCode,R_C_Count=df[[i]]$Counting)})))
is my output:
i want replace the 0 and 1 with label names.