【发布时间】:2017-11-14 12:18:59
【问题描述】:
我正面临 R 中 JSON 对象命名的问题。
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)))
我希望标签名称与此处的 JSON 对象名称相同 我正在尝试使用以下代码,但它没有给出正确的答案
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)})))
是我的输出:
我想用标签名称替换 0 和 1。
【问题讨论】: