{"id":15555442,"url":"https://github.com/sckott/jqr","last_synced_at":"2025-03-29T02:45:03.305Z","repository":{"id":140973532,"uuid":"20336856","full_name":"sckott/jqr","owner":"sckott","description":"jq inspired json parsing","archived":false,"fork":false,"pushed_at":"2014-05-30T17:56:35.000Z","size":128,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T23:36:11.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sckott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-30T17:31:09.000Z","updated_at":"2017-10-23T00:17:18.000Z","dependencies_parsed_at":"2023-03-13T10:39:37.305Z","dependency_job_id":null,"html_url":"https://github.com/sckott/jqr","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/sckott%2Fjqr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sckott%2Fjqr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sckott%2Fjqr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sckott%2Fjqr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sckott","download_url":"https://codeload.github.com/sckott/jqr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246131244,"owners_count":20728299,"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":[],"created_at":"2024-10-02T15:09:21.660Z","updated_at":"2025-03-29T02:45:03.276Z","avatar_url":"https://github.com/sckott.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"jqr\n========\n\nA json parser in R inspired by [`jq`](http://stedolan.github.io/jq/).\n\n### Quick start\n\nInstall\n\n```coffee\ndevtools::install_github(\"sckott/jqr\")\n```\n\nFunctions\n\n```coffee\n# json parser to list\njq \u003c- function(json, ...){\n  json %\u003e% fromJSON(simplifyVector = FALSE, ...)\n}\n\n# extract named elements from list\n`%v%` \u003c- function(input, vars){\n  if(length(vars) \u003e 1){\n    lapply(input, function(x) x[vars])\n  } else {\n    sapply(input, function(x) x[[vars]])\n  }\n}\n\n# Extract single node\n`%s%` \u003c- function(input, vars) input[[vars]]\n\n# key-value, rename keys\nkv \u003c- function(x, ...){\n  args \u003c- list(...)\n  toget \u003c- unname(do.call(c, args))\n  lapply(x, function(z){\n    names(z) \u003c- names(args)\n    z\n  })\n}\n```\n\nLoad some libraries\n\n```coffee\nlibrary(\"jsonlite\")\nlibrary(\"magrittr\")\nlibrary(\"httr\")\nlibrary(\"data.table\")\n```\n\nGet some data\n\n```coffee\njson \u003c- content(GET('http://api.plos.org/search/?q=*:*\u0026wt=json'), as = \"text\")\n```\n\nParse\n\n_note how you can index multiple levels down (here, `response.docs`, would normally be object$response$docs) the list with `%s%`_\n\n```coffee\njson %\u003e%\n  jq %s%\n  'response.docs' %v%\n  c('id','journal') %\u003e%\n  rbindlist\n```\n\n```coffee\n                                                     id  journal\n 1:                  10.1371/journal.pone.0075723/title PLoS ONE\n 2:                        10.1371/journal.pone.0087935 PLoS ONE\n 3:                  10.1371/journal.pone.0087935/title PLoS ONE\n 4:               10.1371/journal.pone.0087935/abstract PLoS ONE\n 5:             10.1371/journal.pone.0087935/references PLoS ONE\n 6:                   10.1371/journal.pone.0087935/body PLoS ONE\n 7:           10.1371/journal.pone.0087935/introduction PLoS ONE\n 8: 10.1371/journal.pone.0087935/results_and_discussion PLoS ONE\n 9:  10.1371/journal.pone.0087935/materials_and_methods PLoS ONE\n10:            10.1371/journal.pone.0087935/conclusions PLoS ONE\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsckott%2Fjqr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsckott%2Fjqr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsckott%2Fjqr/lists"}