{"id":21723582,"url":"https://github.com/chrismuir/jsonparse","last_synced_at":"2025-04-12T22:05:39.938Z","repository":{"id":101313360,"uuid":"154914956","full_name":"ChrisMuir/jsonparse","owner":"ChrisMuir","description":"Fast JSON Parser for R","archived":false,"fork":false,"pushed_at":"2018-11-18T06:07:41.000Z","size":39,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T22:05:36.275Z","etag":null,"topics":["json","r","rapidjson","rstats"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChrisMuir.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-27T02:15:35.000Z","updated_at":"2025-03-13T17:21:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"0822fc45-5b57-417d-8679-8c2f5307ec41","html_url":"https://github.com/ChrisMuir/jsonparse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisMuir%2Fjsonparse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisMuir%2Fjsonparse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisMuir%2Fjsonparse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChrisMuir%2Fjsonparse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChrisMuir","download_url":"https://codeload.github.com/ChrisMuir/jsonparse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637769,"owners_count":21137538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","r","rapidjson","rstats"],"created_at":"2024-11-26T02:40:28.393Z","updated_at":"2025-04-12T22:05:39.928Z","avatar_url":"https://github.com/ChrisMuir.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"## NOTE\n\nI'm currently working with the [SymbolixAU](https://github.com/SymbolixAU) team to add the code/functionality from this package into their CRAN package [jsonify](https://github.com/SymbolixAU/jsonify). If that all works out as planned, then all future development of this code will be happening in that repo.\n\n# jsonparse\n\nR package for parsing JSON. There are already a few R packages that parse JSON data ( [jsonlite](https://github.com/jeroen/jsonlite), [rjson](https://github.com/alexcb/rjson) ), the intent behind this one is to try to build a package that is faster than the existing options. This project is very young, currently the functions can only handle values of type `int`, `double`, `logical`, and `character`.\n\nThis package is built using the [rapidjson](https://github.com/Tencent/rapidjson) C++ library (via the [rapidjsonr](https://github.com/SymbolixAU/rapidjsonr) R package), and [Rcpp](https://github.com/RcppCore/Rcpp).\n\nAs an additional resource, check out the [jsonify](https://github.com/SymbolixAU/jsonify) package, which uses the rapidjson library to convert R objects to json.\n\nPlease [report](https://github.com/ChrisMuir/jsonparse/issues) issues, comments, or feature requests.\n\n## Installation\n\nInstall from this repo:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"ChrisMuir/jsonparse\")\n```\n\n## Example Usage\n\n```r\nlibrary(jsonparse)\nlibrary(jsonify)\n```\n```r\n# Create json string, using package jsonify\njson_str \u003c- jsonify::to_json(\n  list(\n    \"string_key\" = \"cats\", \n    \"int_key\" = 5L, \n    \"double_key\" = 99.4, \n    \"bool_key\" = TRUE, \n    \"vector_key\" = c(9L, 10L, 11L, 12L), \n    \"list_key\" = list(\"dogs\", 55.3)\n  )\n)\n\n# print json_str\njson_str\n```\n```\n#\u003e {\"string_key\":[\"cats\"],\"int_key\":[5],\"double_key\":[99.4],\"bool_key\":[true],\"vector_key\":[9,10,11,12],\"list_key\":[[\"dogs\"],[55.3]]}\n\n```\n```r\njsonparse::from_json(json_str)\n```\n```\n#\u003e $string_key\n#\u003e [1] \"cats\"\n\n#\u003e $int_key\n#\u003e [1] 5\n\n#\u003e $double_key\n#\u003e [1] 99.4\n\n#\u003e $bool_key\n#\u003e [1] TRUE\n\n#\u003e $vector_key\n#\u003e [1]  9 10 11 12\n\n#\u003e $list_key\n#\u003e $list_key[[1]]\n#\u003e [1] \"dogs\"\n\n#\u003e $list_key[[2]]\n#\u003e [1] 55.3\n```\n\n## Benchmarks\n\n```r\nlibrary(jsonlite)\njl_fromJSON \u003c- jsonlite::fromJSON\nlibrary(rjson)\nrj_fromJSON \u003c- rjson::fromJSON\n```\n\n#### Test 1\n```r\njson_str \u003c- jsonify::to_json(\n  list(\n    \"ints\" = 1L:100000L, \n    \"doubles\" = rnorm(100000), \n    \"strings\" = stringi::stri_rand_strings(100000, 8), \n    \"bools\" = sample(c(TRUE, FALSE), size = 100000, replace = TRUE)\n  )\n)\n\nmicrobenchmark::microbenchmark(\n  jsonparse = from_json(json_str), \n  rjson = rj_fromJSON(json_str), \n  jsonlite = jl_fromJSON(json_str, simplifyVector = FALSE)\n)\n```\n```\n#\u003e Unit: milliseconds\n#\u003e      expr       min        lq      mean    median       uq       max neval\n#\u003e jsonparse  24.01423  27.23423  29.97406  29.60571  32.0372  44.45918   100\n#\u003e     rjson 100.33898 109.40579 119.47500 117.18489 126.3026 226.08668   100\n#\u003e  jsonlite 207.57313 219.68605 230.28911 226.09717 239.4743 277.65422   100\n```\n\n#### Test 2\n```r\njson_str \u003c- lapply(1:10000, function(x) {\n  list(\n    \"string_key\" = \"cats\", \n    \"int_key\" = 5L, \n    \"double_key\" = 99.4, \n    \"bool_key\" = TRUE, \n    \"vector_key\" = c(9L, 10L, 11L, 12L), \n    \"list_key\" = list(\"dogs\", 55.3)\n  )\n})\njson_str \u003c- jsonify::to_json(json_str)\n\nmicrobenchmark::microbenchmark(\n  jsonparse = from_json(json_str), \n  rjson = rj_fromJSON(json_str), \n  jsonlite = jl_fromJSON(json_str, simplifyVector = FALSE)\n)\n```\n```\n#\u003e Unit: milliseconds\n#\u003e      expr       min        lq      mean    median        uq      max neval\n#\u003e jsonparse  15.64111  17.31473  22.00976  19.56679  22.38043 105.1796   100\n#\u003e     rjson  39.75470  47.17560  57.10193  52.63964  60.26783 168.0407   100\n#\u003e  jsonlite 106.23252 111.21012 118.63235 115.01797 119.71804 238.5919   100\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismuir%2Fjsonparse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrismuir%2Fjsonparse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismuir%2Fjsonparse/lists"}