Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

[BUG] df_to_json generates empty json file #305

Open
4 of 5 tasks
chainsawriot opened this issue Mar 10, 2022 · 0 comments
Open
4 of 5 tasks

[BUG] df_to_json generates empty json file #305

chainsawriot opened this issue Mar 10, 2022 · 0 comments

Comments

@chainsawriot
Copy link
Collaborator

chainsawriot commented Mar 10, 2022

Please confirm the following

  • I have searched the existing issues
  • The behaviour of the program is deviated from what is described in the documentation.
  • I can reproduce this problem for more than one time.
  • This is NOT a 3-digit error -- it does not display an error message like something went wrong. Status code: 400.
  • This is a 3-digit error and I have consulted the Understanding API errors vignette and the suggestions do not help.

Describe the bug

ref #304

The internal function df_to_json generates empty data_.json when there is no data slot in the input df (BTW, this name is extremely confusing because df is actually a list, not a dataframe as the name implies).

Expected Behavior

When the input df doesn't have the data, it shouldn't write a json.

Steps To Reproduce

require(academictwitteR)
#> Loading required package: academictwitteR

tempdir <- academictwitteR:::.gen_random_dir()
academictwitteR:::create_data_dir(tempdir, verbose = FALSE)
whatever <- list()

academictwitteR:::df_to_json(df = whatever, data_path = tempdir)
list.files(tempdir)
#> [1] "data_.json"  "users_.json"

whatever$data <- iris
whatever$data$id <- 123
whatever$includes <- mtcars

academictwitteR:::df_to_json(df = whatever, data_path = tempdir)
list.files(tempdir)
#> [1] "data_.json"     "data_123.json"  "users_.json"    "users_123.json"

require(academictwitteR)
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=de_DE.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] academictwitteR_0.3.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] knitr_1.37        magrittr_2.0.2    usethis_2.1.5     R.cache_0.15.0   
#>  [5] rlang_1.0.2       fastmap_1.1.0     fansi_1.0.2       stringr_1.4.0    
#>  [9] styler_1.6.2      highr_0.9         tools_4.1.2       xfun_0.29        
#> [13] R.oo_1.24.0       utf8_1.2.2        cli_3.2.0         withr_2.5.0      
#> [17] htmltools_0.5.2   ellipsis_0.3.2    yaml_2.3.5        digest_0.6.29    
#> [21] tibble_3.1.6      lifecycle_1.0.1   crayon_1.5.0      purrr_0.3.4      
#> [25] R.utils_2.11.0    vctrs_0.3.8       fs_1.5.2          glue_1.6.2       
#> [29] evaluate_0.14     rmarkdown_2.11    reprex_2.0.1      stringi_1.7.6    
#> [33] compiler_4.1.2    pillar_1.7.0      R.methodsS3_1.8.1 backports_1.4.1  
#> [37] jsonlite_1.8.0    pkgconfig_2.0.3

Created on 2022-03-10 by the reprex package (v2.0.1)

Anything else?

No response

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

No branches or pull requests

1 participant