我有一个JSON文件.虽然原始文件非常大,但出于这个问题的目的,我将其缩减为一个小得多的可重现示例(无论大小如何,我仍然会得到相同的错误):
{
"relationships_followers": [
{
"title": "",
"media_list_data": [
],
"string_list_data": [
{
"href": "https://www.instagram.com/testaccount1",
"value": "testaccount1",
"timestamp": 1669418204
}
]
},
{
"title": "",
"media_list_data": [
],
"string_list_data": [
{
"href": "https://www.instagram.com/testaccount2",
"value": "testaccount2",
"timestamp": 1660426426
}
]
},
{
"title": "",
"media_list_data": [
],
"string_list_data": [
{
"href": "https://www.instagram.com/testaccount3",
"value": "testaccount3",
"timestamp": 1648230499
}
]
},
{
"title": "",
"media_list_data": [
],
"string_list_data": [
{
"href": "https://www.instagram.com/testaccount4",
"value": "testaccount4",
"timestamp": 1379513403
}
]
}
]
}
我正在try 将其转换为R中的数据帧,其中包含href
、value
和timestamp
个变量的值:
但是,当我运行以下命令时,我从另一个so答案中摘取了关于将JSON转换为R的答案:
library("rjson")
result <- fromJSON(file = "test_file.json")
json_data_frame <- as.data.frame(result)
我遇到了这个关于不同行的错误.
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE, :
arguments imply differing number of rows: 1, 0
如何才能将我所拥有的内容转换为所需的df格式?