如何分割这个疯狂的弦?

时间:2019-03-27 17:46:41

标签: r

Current Data


Sr. Genres
1   [{"id": 28, "name": "Action"}, {"id": 12, "name": "Adventure"}, {"id": 14, "name": "Fantasy"}, {"id": 878, "name": "Science Fiction"}]
2   [{"id": 12, "name": "Adventure"}, {"id": 14, "name": "Fantasy"}, {"id": 28, "name": "Action"}]
3   [{"id": 28, "name": "Action"}, {"id": 12, "name": "Adventure"}, {"id": 80, "name": "Crime"}]
4   [{"id": 28, "name": "Action"}, {"id": 80, "name": "Crime"}, {"id": 18, "name": "Drama"}, {"id": 53, "name": "Thriller"}]
5   [{"id": 28, "name": "Action"}, {"id": 12, "name": "Adventure"}, {"id": 878, "name": "Science Fiction"}]

必需的输出

Sr. id  name    id  name    id  name    id  name
1   28  Action  12  Adventure   14  Fantasy 878 Science Fiction
2   12  Adventure   14  Fantasy 28  Action      
3   28  Action  12  Adventure   80  Crime   53  Thriller
4   28  Action  80  Crime   18  Drama       
5   28  Action  12  Adventure   878 Science Fiction     

有什么帮助吗?

1 个答案:

答案 0 :(得分:0)

只需使用RJSON包。 ...

#First install JSON Package:
install.packages("rjson")

# Load the package to your workspace
library(rjson)

# read your input file, assuming this is called input.json
result <- fromJSON(file = "input.json")

# Print the result.
out <- as.data.frame(result)

# Then export it
write.table(out,file="out.txt",sep="\t",col.names=T,row.names=F)