M.van_Iterson at lumc.nl
2014-Mar-07 09:07 UTC
[R] RJSONIO: toJSON integer conversion problem
Dear all, I encounter a conversion problem with integers to JSON format. Are there any options in RJSONIO to make a proper conversion from int to int instead of int to float with the consequence of losing accuracy? Regards, Maarten> doc <- 8667053102 > names(doc) <- "largeint" > toJSON(doc)[1] "{\n \"largeint\": 8.6671e+09 \n}"> sessionInfo()R Under development (unstable) (2013-11-11 r64202) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RJSONIO_1.0-3 [[alternative HTML version deleted]]
try: toJSON(doc, digits = 20) Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. On Fri, Mar 7, 2014 at 4:07 AM, <M.van_Iterson@lumc.nl> wrote:> Dear all, > > I encounter a conversion problem with integers to JSON format. Are there > any options in RJSONIO to make a proper conversion from int to int instead > of int to float with the consequence of losing accuracy? > > Regards, > Maarten > > > > doc <- 8667053102 > > names(doc) <- "largeint" > > toJSON(doc) > [1] "{\n \"largeint\": 8.6671e+09 \n}" > > > sessionInfo() > R Under development (unstable) (2013-11-11 r64202) > Platform: x86_64-unknown-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C > [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 > [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 > [7] LC_PAPER=en_US.UTF-8 LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] RJSONIO_1.0-3 > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]