Update from 2018: use jsonlite
like everyone nowadays:
> toJSON(c(1200000000, 400000))
[1200000000,400000]
Original answer from 2012:
I would also suggest to transform the numbers to strings before passing to toJSON
just as @gauden wrote above. But if you would not do that try RJSONIO
package (which is faster anyway) which has a digits
option:
> toJSON(c(1200000000, 400000), digits = 10)
[1] "[ 1200000000, 400000 ]"
But this would result in some extra whitespace as you can see.
Update: it seems that @gauden deleted his answer so adding some details
You might call e.g. format
before transforming the "numbers" to JSON like:
> toJSON(format(c(1200000000, 400000), scientific = FALSE, trim = TRUE))
[1] "[\"1200000000\",\"400000\"]"