Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding argument fails with simplifyVector = TRUE #338

Closed
MansMeg opened this issue Nov 22, 2020 · 2 comments
Closed

Encoding argument fails with simplifyVector = TRUE #338

MansMeg opened this issue Nov 22, 2020 · 2 comments

Comments

@MansMeg
Copy link

MansMeg commented Nov 22, 2020

Hi!

I get the following errors when using simplifyVector. I assume this is not a behavior we would expect/is intended?

> writeLines(text = jsonlite::toJSON("Måns"), con = "test.txt")
> jsonlite::read_json("test.txt", encoding = "UTF-8", simplifyVector = FALSE)
[[1]]
[1] "Måns"

> jsonlite::read_json("test.txt", encoding = "UTF-8", simplifyVector = TRUE)
Error in simplify(obj, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame,  : 
  unused argument (encoding = "UTF-8")
> jsonlite::fromJSON("test.txt", encoding = "UTF-8", simplifyVector = FALSE)
[[1]]
[1] "Måns"

> jsonlite::fromJSON("test.txt", encoding = "UTF-8", simplifyVector = TRUE)
Error in simplify(obj, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame,  : 
  unused argument (encoding = "UTF-8")


> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] sv_SE.UTF-8/sv_SE.UTF-8/sv_SE.UTF-8/C/sv_SE.UTF-8/sv_SE.UTF-8

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

loaded via a namespace (and not attached):
 [1] compiler_4.0.2   assertthat_0.2.1 cli_2.0.2        tools_4.0.2     
 [5] glue_1.4.2       rstudioapi_0.11  yaml_2.2.1       crayon_1.3.4    
 [9] fansi_0.4.1      jsonlite_1.7.1   rlang_0.4.7 
@MansMeg MansMeg changed the title encoding argument fails with simplify = TRUE encoding argument fails with simplifyVector = TRUE Nov 22, 2020
@MansMeg MansMeg changed the title encoding argument fails with simplifyVector = TRUE Encoding argument fails with simplifyVector = TRUE Nov 22, 2020
@jeroen
Copy link
Owner

jeroen commented Nov 23, 2020

There is no encoding parameter in read_json(), where did you get this? JSON is always utf-8 by definition.

@jeroen jeroen closed this as completed Nov 23, 2020
@MansMeg
Copy link
Author

MansMeg commented Nov 23, 2020

The problem was that I have JSON without UTF8 (dont ask me why). I tried using the encoding argument, default in readLines(), through ... in read_json() and got this inconsistent behaviour.

I solved it in two steps now, but wanted to give you a heads up about that ... is affected by simplifyVector. Im not sure if that is intentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants