duncantl / RJSONIO

Serialize to and from R and JSON, JavaScript Object Notation
http://www.omegahat.org/RJSONIO
Other
25 stars 68 forks source link

infinite recursion error for toJSON(fun) #12

Open tdhock opened 10 years ago

tdhock commented 10 years ago

Can you please stop with a more informative error? e.g. toJSON does not support converting R functions to JSON.

> toJSON(identity)
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
> toJSON(function(x) x)
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=en_CA.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats4    grid      graphics  utils     datasets  grDevices stats    
[8] methods   base     

other attached packages:
 [1] flexclust_1.3-4        modeltools_0.2-21      animint_2014.4.7      
 [4] scales_0.2.3           hexbin_1.26.3          MASS_7.3-29           
 [7] reshape2_1.2.2         maps_2.3-6             proto_0.3-10          
[10] directlabels_2014.1.31 quadprog_1.5-5         glmnet_1.9-5          
[13] Matrix_1.0-14          RColorBrewer_1.0-5     lattice_0.20-23       
[16] plotly_0.3.8           plyr_1.8.1             ggplot2_0.9.3.1       
[19] RJSONIO_1.0-3          RCurl_1.95-4.1         bitops_1.0-6          

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4 compiler_3.0.2   dichromat_2.0-0  digest_0.6.4    
 [5] evaluate_0.5.1   formatR_0.10     gtable_0.1.2     knitr_1.5       
 [9] labeling_0.2     munsell_0.4.2    parallel_3.0.2   Rcpp_0.11.0     
[13] stringr_0.6.2    tools_3.0.2     
duncantl commented 10 years ago

I've added a method for toJSON() for the class "function". One can always add methods to override the default behavior. That was part of the design so that people could customize for different scenarios. Thanks D.