ropensci / jqr

R interface to jq
https://docs.ropensci.org/jqr
Other
143 stars 13 forks source link

Encoding with jqr::jq #71

Closed maelle closed 6 years ago

maelle commented 6 years ago

I've noticed this when parsing GitHub API V4 results with my name in it. 😢 Minimal example:

x <- '[{"message": "hello", "name": "Maëlle"},
  {"message": "world", "name": "beth"}]'
jqr::jq(x, ".[].name")
#> [
#>     "Ma�lle",
#>     "beth"
#> ]

Created on 2018-04-23 by the reprex package (v0.2.0).

Session info ``` r devtools::session_info() #> Session info ------------------------------------------------------------- #> setting value #> version R version 3.4.4 (2018-03-15) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.1252 #> tz Europe/Paris #> date 2018-04-23 #> Packages ----------------------------------------------------------------- #> package * version date source #> backports 1.1.2 2017-12-13 CRAN (R 3.4.3) #> base * 3.4.4 2018-03-15 local #> compiler 3.4.4 2018-03-15 local #> datasets * 3.4.4 2018-03-15 local #> devtools 1.13.5 2018-02-18 CRAN (R 3.4.3) #> digest 0.6.15 2018-01-28 CRAN (R 3.4.3) #> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.3) #> graphics * 3.4.4 2018-03-15 local #> grDevices * 3.4.4 2018-03-15 local #> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.0) #> jqr 1.0.0 2017-09-28 CRAN (R 3.4.3) #> jsonlite 1.5.9000 2018-04-23 Github (jeroen/jsonlite@ae0ef71) #> knitr 1.20 2018-02-20 CRAN (R 3.4.4) #> lazyeval 0.2.1 2017-10-29 CRAN (R 3.4.2) #> magrittr 1.5 2014-11-22 CRAN (R 3.4.0) #> memoise 1.1.0 2017-04-21 CRAN (R 3.4.0) #> methods * 3.4.4 2018-03-15 local #> Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4) #> rmarkdown 1.9 2018-03-01 CRAN (R 3.4.4) #> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3) #> stats * 3.4.4 2018-03-15 local #> stringi 1.1.7 2018-03-12 CRAN (R 3.4.4) #> stringr 1.3.0.9000 2018-02-28 Github (tidyverse/stringr@097c0c0) #> tools 3.4.4 2018-03-15 local #> utils * 3.4.4 2018-03-15 local #> withr 2.1.2 2018-03-15 CRAN (R 3.4.4) #> yaml 2.1.18 2018-03-08 CRAN (R 3.4.4) ```
sckott commented 6 years ago

does it still mess up if you assign it to an object and then unclass it? wonder if the print statement messes it up, or if it's already messed up

maelle commented 6 years ago

hmmm not sure what you mean.

The actual context in which I noticed this was using https://github.com/ropenscilabs/ghrecipes/blob/master/R/get_master_committers.R for ropensci/codemetar

sckott commented 6 years ago

like

z <- jqr::jq(x, ".[].name")
unclass(z)
maelle commented 6 years ago
x <- '[{"message": "hello", "name": "Maëlle"},
  {"message": "world", "name": "beth"}]'
z <- jqr::jq(x, ".[].name")
unclass(z)
#> [1] "\"Ma�lle\"" "\"beth\""

Created on 2018-04-23 by the reprex package (v0.2.0).

Session info ``` r devtools::session_info() #> Session info ------------------------------------------------------------- #> setting value #> version R version 3.4.4 (2018-03-15) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.1252 #> tz Europe/Paris #> date 2018-04-23 #> Packages ----------------------------------------------------------------- #> package * version date source #> backports 1.1.2 2017-12-13 CRAN (R 3.4.3) #> base * 3.4.4 2018-03-15 local #> compiler 3.4.4 2018-03-15 local #> datasets * 3.4.4 2018-03-15 local #> devtools 1.13.5 2018-02-18 CRAN (R 3.4.3) #> digest 0.6.15 2018-01-28 CRAN (R 3.4.3) #> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.3) #> graphics * 3.4.4 2018-03-15 local #> grDevices * 3.4.4 2018-03-15 local #> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.0) #> jqr 1.0.0 2017-09-28 CRAN (R 3.4.3) #> knitr 1.20 2018-02-20 CRAN (R 3.4.4) #> lazyeval 0.2.1 2017-10-29 CRAN (R 3.4.2) #> magrittr 1.5 2014-11-22 CRAN (R 3.4.0) #> memoise 1.1.0 2017-04-21 CRAN (R 3.4.0) #> methods * 3.4.4 2018-03-15 local #> Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4) #> rmarkdown 1.9 2018-03-01 CRAN (R 3.4.4) #> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3) #> stats * 3.4.4 2018-03-15 local #> stringi 1.1.7 2018-03-12 CRAN (R 3.4.4) #> stringr 1.3.0.9000 2018-02-28 Github (tidyverse/stringr@097c0c0) #> tools 3.4.4 2018-03-15 local #> utils * 3.4.4 2018-03-15 local #> withr 2.1.2 2018-03-15 CRAN (R 3.4.4) #> yaml 2.1.18 2018-03-08 CRAN (R 3.4.4) ```
sckott commented 6 years ago

bummer, will see where that's happening.

maelle commented 6 years ago

I am the truffle hog of Windows encoding issues 🐷

jeroen commented 6 years ago

Thanks Ma�lle! 🐗