Btibert3
10/26/2013 - 10:43 PM

Parse JSONP with R

Parse JSONP with R

# http://stackoverflow.com/questions/9455437/parse-jsonp-with-r/9463929#9463929
j  <- readLines('http://live.nhl.com/GameData/20112012/2011020908/Roster.jsonp')
j <- sub('[^\\{]*', '', j) # remove function name and opening parenthesis
j <- sub('\\)$', '', j) # remove closing parenthesis
library(rjson)
res <- fromJSON(j)