【问题标题】:Exporting JSON to text file将 JSON 导出到文本文件
【发布时间】:2018-05-25 14:59:03
【问题描述】:

无法将 json 字符串导出到文本文件 -

> tester <- list(10, 20) %>% 
          toJSON(. , auto_unbox = T)
> write.table(tester, file = "JSONfile.txt", sep = "")
Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) : 
  cannot coerce class ""json"" to a data.frame

有没有其他方法可以将 JSON 导出为文本?

【问题讨论】:

标签: r json


【解决方案1】:

可以试试

sink("./JSONfile.txt")
list(10, 20) %>% toJSON(. , auto_unbox = T) %>% cat
sink()

【讨论】:

    猜你喜欢
    • 2016-02-20
    • 1970-01-01
    • 2013-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多