if (FALSE) {
xx = '[1,2, 3]{"a": [true, false]}'
con = textConnection(xx)
f = function(x)
print(sum(unlist(x)))
readJSONStream(con, f)
# The callback function can be anonymous
con = textConnection(xx)
readJSONStream(con, function(x)
print(sum(unlist(x))))
gen =
function() {
ans <- 0
list(update = function(x) ans <<- ans + sum(unlist(x)),
value = function() ans)
}
g = gen()
con = textConnection(xx)
readJSONStream(con, g$update)
}
Run the code above in your browser using DataLab