1

How do I override that all items in JSON are converted to string?

When I run

require("RJSONIO")
toJSON(structure(c("nonce", as.integer(5487)), names = c("nonce", "price"), class = c("character", "integer")))

I would expect this

"{\n \"nonce\": \"nonce\",\n\"price\": \5487\ \n}"

but I'm getting this

"{\n \"nonce\": \"nonce\",\n\"price\": \"5487\" \n}"

so the price = 5487 is still as string.

Steef Gregor
  • 544
  • 1
  • 7
  • 21
  • 5
    This is expected behavior and NOT a problem with `toJSON`. Note that `c("nonce", as.integer(5487))` will be treated as a character vector, and so `5487` will be coerced to character. Use `list("nonce", 5487)` if you want the types to be retained. – Ramnath Dec 04 '14 at 18:25

0 Answers0