0

I have a Json that contains data such as "id" : "165436382098949", but when I try to parse the string using fromJSON, I get something as

$data[[1]]$id
[1] 1.654364e+14

Which is a nuisance since I need the exact id to perform requests. How can I force fromJSON to read all fields as characters?

Edit: example

> x <- fromJSON('[{"id" : 323907258301939713}]')
> as.character(x)
[1] "323907258301939712"
  • You can [turn this nuisance off](https://stackoverflow.com/questions/5352099/how-to-disable-scientific-notation-in-r) – pogibas Feb 06 '18 at 13:31
  • It doesn't guarantee that the ids will have the same value as the string. I don't want this function parsing the ids as numbers at all. – Lucio Carlos Pimentel Paiva Feb 06 '18 at 13:40
  • What about ´as.character()´? Also, as R print out a limited number of decimals, but the value is exactly the same, you can change the number of decimals printed using ´options(digits=x)´, but remember, the value is the same, is just that R doesn't show a big big number. I don't know if I exactly understand your problem though, but hope it helps. – Cris Feb 06 '18 at 13:43
  • as.character is useless if the id has already been parsed. I want to avoid parsing the id as a number in the first place – Lucio Carlos Pimentel Paiva Feb 06 '18 at 13:46
  • 1
    I don't have this problem, maybe you need to show more of your Json file and/or your full call – RolandASc Feb 06 '18 at 13:52

0 Answers0