converting bibtex to json

is there an R package that converts bibtex to json? i tried using refManagR to read in the bib file but got stuck on a common bug found in the bibtex package.

<simpleError in do_read_bib(file, encoding = .Encoding, srcfile): lex fatal error:
input buffer overflow, can't enlarge buffer because scanner uses REJECT
>

<simpleError in do_read_bib(file, encoding = .Encoding, srcfile): lex fatal error:
fatal flex scanner internal error--end of buffer missed
>

There is a new pkg I’ve been working on handlr that might help. By json do you mean citeproc json? or something else?

z <- system.file('extdata/bibtex.bib', package = "handlr")
x <- HandlrClient$new(x = z)
x$read("bibtex")
x$write("citeproc")
{
  "type": "article-journal",
  "id": "https://doi.org/10.1142%2fs1363919602000495",
  "categories": [],
  "language": {},
  "author": [
    {
      "type": "Person",
      "family": "DODGSON",
      "given": "MARK",
      "literal": "DODGSON"
    },
    {
      "type": "Person",
      "family": "GANN",
      "given": "DAVID M.",
      "literal": "GANN"
    },
    {
      "type": "Person",
      "family": "SALTER",
      "given": "AMMON. J",
      "literal": "SALTER"
    }
  ],
  "editor": [],
  "issued": {
    "date-parts": {}
  },
  "submitted": {
    "date-parts": {}
  },
  "abstract": {},
  "container-title": {},
  "DOI": "10.1142/s1363919602000495",
  "issue": {},
  "page": "5383",
  "publisher": "World Scientific Pub Co Pte Lt",
  "title": "{THE} {INTENSIFICATION} {OF} {INNOVATION}",
  "URL": "https://doi.org/10.1142%2Fs1363919602000495",
  "version": {},
  "volume": "06"
}

that looks great. i’ll give it a try, thanks!

x <- handlr::HandlrClient$new(x = '~/Desktop/mrg.bib')
x$read("bibtex")
Error in do_read_bib(file, encoding = .Encoding, srcfile) : 
  lex fatal error:
input buffer overflow, can't enlarge buffer because scanner uses REJECT
session info
> devtools::session_info()
Session info --------------------------------------------------------------
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 system   x86_64, darwin15.6.0        
 ui       RStudio (1.2.1162)          
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/New_York            
 date     2018-12-18                  

Packages ------------------------------------------------------------------
 package    * version    date       source                          
 base       * 3.5.1      2018-07-05 local                           
 bibtex       0.4.2      2017-06-30 CRAN (R 3.5.0)                  
 compiler     3.5.1      2018-07-05 local                           
 crul         0.6.0      2018-07-10 CRAN (R 3.5.0)                  
 curl         3.2        2018-03-28 CRAN (R 3.5.0)                  
 datasets   * 3.5.1      2018-07-05 local                           
 devtools     1.13.6     2018-06-27 CRAN (R 3.5.0)                  
 digest       0.6.18     2018-10-10 CRAN (R 3.5.0)                  
 graphics   * 3.5.1      2018-07-05 local                           
 grDevices  * 3.5.1      2018-07-05 local                           
 handlr     * 0.0.4.9210 2018-12-19 Github (ropensci/handlr@0252efc)
 httpcode     0.2.0      2016-11-14 CRAN (R 3.5.0)                  
 httr         1.4.0      2018-12-11 CRAN (R 3.5.0)                  
 jsonlite     1.6        2018-12-07 CRAN (R 3.5.0)                  
 lubridate    1.7.4      2018-04-11 CRAN (R 3.5.0)                  
 magrittr     1.5        2014-11-22 CRAN (R 3.5.0)                  
 memoise      1.1.0      2017-04-21 CRAN (R 3.5.0)                  
 methods    * 3.5.1      2018-07-05 local                           
 packrat      0.4.9-3    2018-06-01 CRAN (R 3.5.0)                  
 plyr         1.8.4      2016-06-08 CRAN (R 3.5.0)                  
 R6           2.3.0      2018-10-04 CRAN (R 3.5.0)                  
 Rcpp         1.0.0      2018-11-07 CRAN (R 3.5.0)                  
 RefManageR   1.2.0      2018-04-25 CRAN (R 3.5.0)                  
 stats      * 3.5.1      2018-07-05 local                           
 stringi      1.2.4      2018-07-20 CRAN (R 3.5.0)                  
 stringr      1.3.1      2018-05-10 CRAN (R 3.5.0)                  
 tools        3.5.1      2018-07-05 local                           
 triebeard    0.3.0      2016-08-04 CRAN (R 3.5.0)                  
 urltools     1.7.1      2018-08-03 CRAN (R 3.5.0)                  
 utils      * 3.5.1      2018-07-05 local                           
 withr        2.1.2      2018-03-15 CRAN (R 3.5.0)                  
 xml2         1.2.0      2018-01-24 CRAN (R 3.5.0)                  

I’ll answer over in the issue

Have you tried https://github.com/ropensci/bib2df? Maybe converting the data.frame bib2df gives you to json is a solution for you?