r - 将 JSON 导出到文本文件
问题描述
无法将 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 导出为文本的替代方法?
解决方案
也许试试
sink("./JSONfile.txt")
list(10, 20) %>% toJSON(. , auto_unbox = T) %>% cat
sink()
推荐阅读
- windows - 在 Windows 上链接 SHARED 库
- spring-boot - AWS Lambda - Spring Boot 未处理请求
- visual-studio - Visual Studio 在括号内快速键入字符串
- compilation - 在 AWS Lambda 上将 PDF 转换为 JPEG
- xamarin - 如何在 XAMARIN android 应用程序中向 HockeyApp SDK 发送已处理的异常?
- firebase - 如何正确跟踪游戏战斗结果游戏分析事件
- java - 为 HANA JDBC 创建一个连接字符串?
- ballerina - 如何确保我的类型和函数文档出现在 Ballerina Central 中?
- socket.io - 是否可以将 Socket.io 与 NuxtJs 一起使用?
- java - 如何防止“Firestore,提供的文档路径不能为空”错误?