{"id":23050384,"url":"https://github.com/atorus-research/datasetjson","last_synced_at":"2025-08-15T03:31:18.322Z","repository":{"id":194321012,"uuid":"687158618","full_name":"atorus-research/datasetjson","owner":"atorus-research","description":"Read and write CDISC Dataset JSON files","archived":false,"fork":false,"pushed_at":"2023-12-19T15:58:10.000Z","size":7791,"stargazers_count":8,"open_issues_count":5,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2023-12-19T16:06:14.562Z","etag":null,"topics":["cdisc","dataset-json","rstats","rstats-package"],"latest_commit_sha":null,"homepage":"https://atorus-research.github.io/datasetjson/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atorus-research.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-09-04T18:51:25.000Z","updated_at":"2024-01-02T17:31:34.922Z","dependencies_parsed_at":"2023-09-12T22:12:10.787Z","dependency_job_id":"5c6f790a-d1b9-4997-bec2-13e3489a2871","html_url":"https://github.com/atorus-research/datasetjson","commit_stats":null,"previous_names":["atorus-research/datasetjson"],"tags_count":2,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atorus-research%2Fdatasetjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atorus-research%2Fdatasetjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atorus-research%2Fdatasetjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atorus-research%2Fdatasetjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atorus-research","download_url":"https://codeload.github.com/atorus-research/datasetjson/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229890140,"owners_count":18140041,"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":["cdisc","dataset-json","rstats","rstats-package"],"created_at":"2024-12-15T23:32:19.879Z","updated_at":"2025-08-15T03:31:18.306Z","avatar_url":"https://github.com/atorus-research.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE)\nlibrary(datasetjson)\n```\n\n# **datasetjson** \u003cimg src=\"man/figures/logo.svg\" align=\"right\" alt=\"\" width=\"120\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[\u003cimg src=\"https://img.shields.io/codecov/c/github/atorus-research/datasetjson\"\u003e](https://app.codecov.io/gh/atorus-research/datasetjson)\n[\u003cimg src=\"https://img.shields.io/badge/License-APACHE2-blue.svg\"\u003e](https://github.com/atorus-research/datasetjson/blob/main/LICENSE.md)\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n\u003c!-- badges: end --\u003e\n\nWelcome to **datasetjson**. **datasetjson** is an R package built to read and write [CDISC Dataset JSON](https://www.cdisc.org/standards/data-exchange/dataset-json) formatted datasets. \n\nIf you're stumbling into the world of Dataset JSON, you might be wondering \"Why JSON?\", as many have asked this question. We highly recommend you take a pit stop to read [this blog post](https://swhume.github.io/why-json-for-datasets) by Sam Hume one of the creators of the Dataset JSON standard. \n\nAs always, we welcome your feedback. If you spot a bug, would like to see a new feature, or if any documentation is unclear - submit an issue through GitHub right [here](https://github.com/atorus-research/datasetjson/issues). \n\n# Installation\n\nYou can install **datasetjson** with:\n\n```{r install, eval=FALSE}\n# Install from CRAN:\ninstall.packages(\"datasetjson\")\n\n# Or install the development version:\ndevtools::install_github(\"https://github.com/atorus-research/datasetjson.git\", ref=\"dev\")\n```\n\n# Using **datasetjson**\n\n**datasetjson** works by allowing you to take a data frame and apply the necessary attributes required for the CDISC Dataset JSON. The goal is to make this experience simple. Before you can write a Dataset JSON file to disk, you first need to build the Dataset JSON object. An example call looks like this:\n\n```{r sample_call}\nds_json \u003c- dataset_json(\n  head(iris, 5),\n  file_oid = \"/some/path\",\n  last_modified = \"2023-02-15T10:23:15\",\n  originator = \"Some Org\",\n  sys = \"source system\",\n  sys_version = \"1.0\",\n  study = \"SOMESTUDY\",\n  metadata_version = \"MDV.MSGv2.0.SDTMIG.3.3.SDTM.1.7\",\n  metadata_ref = \"some/define.xml\",\n  item_oid = \"IG.IRIS\",\n  name = \"IRIS\",\n  dataset_label = \"Iris\",\n  columns = iris_items\n)\n```\n\nTo attach necessary metadata (that can't be inferred by the input dataframe or at time of write) to the `datasetjson` object, you can use a variety of setter functions:\n\n```{r setters}\nds_json \u003c- dataset_json(\n    head(iris, 5),\n    item_oid = \"IG.IRIS\",\n    name = \"IRIS\",\n    dataset_label = \"Iris\",\n    columns = iris_items\n  ) |\u003e\n  set_file_oid(\"/some/path\") |\u003e\n  set_last_modified(\"2025-01-21T13:34:50\") |\u003e\n  set_originator(\"Some Org\") |\u003e\n  set_source_system(\"source system\", \"1.0\") |\u003e\n  set_study_oid(\"SOMESTUDY\") |\u003e\n  set_metadata_ref(\"some/define.xml\") |\u003e\n  set_metadata_version(\"MDV.MSGv2.0.SDTMIG.3.3.SDTM.1.7\")\n```\n\nOnce the `datasetjson` object is prepared with the necessary metadata, you can use `write_dataset_json()` to write the file to disk. \n\n```{r write_disk, eval=FALSE}\nwrite_dataset_json(ds_json, file = \"./iris.json\")\n```\n\nOr if you don't provide a file path, the JSON text will return directly. \n\n```{r write_print}\njs_text \u003c- write_dataset_json(ds_json, pretty=TRUE)\ncat(js_text)\n```\n\nTo read a Dataset JSON file, you can use `read_dataset_json()`. You can either provide the path to a JSON file, or if you already have the JSON text loaded into a character string, you can provide that directly.\n\n```{r read}\ndat \u003c- read_dataset_json(js_text)\ndat\n```\n\nThe data frame that's returned is enriched with attributes available in the Dataset JSON format. For example, opening the dataframe within the RStudio IDE will present the variable labels. All the other metadata contained within the Dataset JSON file is attached as attributes to the resulting dataframe.\n\n```{r dataframe_attributes}\nprint(attr(dat, 'dbLastModifiedDateTime'))\nprint(attr(dat, 'fileOID'))\n```\n\nThis package currently supports Dataset JSON Version 1.1.0. Support for Version 1.0.0 has been dropped, as version 1.1.0 is intended to be the first stable version of the standard. \n\n# [\u003cimg src=\"man/figures/cdisc.png\" alt=\"\" width=\"120\" /\u003e](https://www.cdisc.org/)\n\n## Acknowledgements\n\nThank you to Ben Straub and Eric Simms (GSK) for help and input during the original CDISC Dataset JSON hackathon that motivated this work.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatorus-research%2Fdatasetjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatorus-research%2Fdatasetjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatorus-research%2Fdatasetjson/lists"}