我有以下JSON文件:
IComparer
我使用了包jsonlite,但是我得到了一个解析错误
{"id":1140854908,"name":"'Amran"}
{"id":1140852651,"name":"'Asir"}
{"id":1140855190,"name":"'Eua"}
{"id":1140851307,"name":"A Coruna"}
{"id":1140854170,"name":"A`Ana"}
答案 0 :(得分:4)
尝试将数据文件更改为
[
{"id":1140854908,"name":"'Amran"}
,{"id":1140852651,"name":"'Asir"}
,{"id":1140855190,"name":"'Eua"}
,{"id":1140851307,"name":"A Coruna"}
,{"id":1140854170,"name":"A`Ana"}
]
相同的代码对我有用..它正在寻找一个数组..
答案 1 :(得分:1)
您的文件是换行符分隔的JSON(http://ndjson.org/)。你可以用jsonlite这样读它:
try <- stream_in(file("states.txt"))