> orioles.tweets <- searchTwitter('#orioles', n=15, lang="en")
> orioles.text=laply(orioles.tweets,function(t) t$getText())
> class(toJSON(orioles.text))
[1] "character"
Why does this happen?
> orioles.tweets <- searchTwitter('#orioles', n=15, lang="en")
> orioles.text=laply(orioles.tweets,function(t) t$getText())
> class(toJSON(orioles.text))
[1] "character"
Why does this happen?
It is unclear why you would think that the class should be "json". Presumably you are using one of the R packages that has a toJSON
function. Choosing the rjsom package as a test case, I find that the first example in ?toJSON
-help page gives "character" as the class for the retruned object:
> ??toJSON
> library(rjson); x <- list( alpha = 1:5, beta = "Bravo",
+ gamma = list(a=1:3, b=NULL),
+ delta = c(TRUE, FALSE) )
> json.vec <- toJSON( x )
> class(json.vec)
[1] "character"
If you are getting errors from subsequent proccessing because the class is not correctly set, you can assign a class:
class(json.vec) <- "json"
This is generally not advised, but it might be needed in situations where the choice of the json-wrangling library was not the same one as was chosen by another package author.