在 r 中导入 json 文件时出现问题
issue importing json file in r
我正在尝试从此 api https://api.ycombinator.com/companies/export.json?callback=true
导入数据
我收到以下错误:
Error in parse_con(txt, bigint_as_char) lexical error: invalid char in json text.
setupCompanies([{"name":"Parake
(right here) ------^
我以为错误是因为表情符号,所以我将文件下载为文本并进行了手动删除。没用
从您的 URL 中删除 ?callback=true
,它可以正常工作:
aa <- jsonlite::fromJSON("https://api.ycombinator.com/companies/export.json")
str(aa)
# 'data.frame': 2055 obs. of 8 variables:
# $ name : chr "Parakey" "Dinesafe" "Pengram" "Demeanor.co" ...
# $ url : chr "http://parakey.com" "https://dinesafe.org" "http://pengramar.com" "https://demeanor.co" ...
# $ batch : chr "s2005" "s2018" "w2019" "s2018" ...
# $ vertical : chr NA "B2B" "Augmented Reality" "Media" ...
# $ description: chr "" "We crowdsource food poisoning reports and help detect and prevent outbreaks." "Pengram provides indoor navigation in augmented reality on your phone. " "Now part of thentwrk.com" ...
# $ dead : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
# $ has_ff : logi NA FALSE FALSE FALSE FALSE FALSE ...
# $ all_ff : logi NA FALSE FALSE FALSE FALSE FALSE ...
我猜测 "callback API" 正在设置 return 值,因此它实际上是一个函数调用(即 setupCompanies(...)
),而不仅仅是数据。
我正在尝试从此 api https://api.ycombinator.com/companies/export.json?callback=true
导入数据我收到以下错误:
Error in parse_con(txt, bigint_as_char) lexical error: invalid char in json text.
setupCompanies([{"name":"Parake
(right here) ------^
我以为错误是因为表情符号,所以我将文件下载为文本并进行了手动删除。没用
从您的 URL 中删除 ?callback=true
,它可以正常工作:
aa <- jsonlite::fromJSON("https://api.ycombinator.com/companies/export.json")
str(aa)
# 'data.frame': 2055 obs. of 8 variables:
# $ name : chr "Parakey" "Dinesafe" "Pengram" "Demeanor.co" ...
# $ url : chr "http://parakey.com" "https://dinesafe.org" "http://pengramar.com" "https://demeanor.co" ...
# $ batch : chr "s2005" "s2018" "w2019" "s2018" ...
# $ vertical : chr NA "B2B" "Augmented Reality" "Media" ...
# $ description: chr "" "We crowdsource food poisoning reports and help detect and prevent outbreaks." "Pengram provides indoor navigation in augmented reality on your phone. " "Now part of thentwrk.com" ...
# $ dead : logi FALSE FALSE FALSE FALSE FALSE FALSE ...
# $ has_ff : logi NA FALSE FALSE FALSE FALSE FALSE ...
# $ all_ff : logi NA FALSE FALSE FALSE FALSE FALSE ...
我猜测 "callback API" 正在设置 return 值,因此它实际上是一个函数调用(即 setupCompanies(...)
),而不仅仅是数据。