Miachol / configr

Implements the JSON, INI, YAML and TOML parser, for R setting and writing of configuration file.
Other
58 stars 7 forks source link

Array in TOML not be parsed #3

Closed obenno closed 4 years ago

obenno commented 4 years ago

Hi

I'm using configr to parse a TOML file. It seems that array in TOML is not correctly parsed.

Please find a minimum working example below:

$ cat test.toml

[input]

bam = [
    "file1",
    "file2",
    "file3"
]
$ Rscript -e 'configr::read.config("test.toml")'
$input
$input$bam
[1] "["
$ Rscript -e 'RcppTOML::parseTOML("test.toml")'
List of 1
 $ input:List of 1
  ..$ bam: chr [1:3] "file1" "file2" "file3"
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/liblapack.so.3

locale:
 [1] LC_CTYPE=en_HK.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_HK.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_HK.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] configr_0.3.4

loaded via a namespace (and not attached):
 [1] compiler_3.6.3 magrittr_1.5   RcppTOML_0.1.6 tools_3.6.3    ini_0.3.1     
 [6] glue_1.3.1     yaml_2.2.0     Rcpp_1.0.3     stringi_1.4.6  stringr_1.4.0 
[11] jsonlite_1.6 

Thanks, oben

Miachol commented 4 years ago

Dear oben,

I think this file was treated as the 'INI' type. You can set the file.type to toml for correct parsing.

I will add the filename check process to fix this. Thanks.

Best wishes, Jianfeng

obenno commented 4 years ago

Hi Jianfeng,

Thanks for the fixing.

Regards, oben