import_json | R Documentation |
Import data model in json format
json_to_dm(json)
json_to_dbml(json, dbml)
json |
Character vector with paths to json files. If more than one file is provided, they will be combined into a single data model. |
dbml |
Path for the DBML output file |
json_to_dm
returns a dm
object.
json_to_dbml
writes a DBML file.
json files to be imported should contain a list "tables". Each table object should contain the following elements:
table: table name
columns: list of "column" objects
required: TRUE indicates the table is required, FALSE or missing if the table is optional. 'CONDITIONAL (t1)' indicates that a table is only required if table 't1' is present.
Each column object can contain the following elements. 'column' and 'data_type' are required.
column: column name
data_type: "string", "boolean, "integer", "float", "date", "dateTime", or "enumeration"
enumerations: if data_type is enumeration, list values here
multi_value_delimiter: if data values may be delimited, this contains the delimiter value
required: TRUE indicates the column is required, FALSE or missing if the column is optional. 'CONDITIONAL (column = value)' indicates a requirement only if any element of 'column' contains 'value'. 'CONDITIONAL (column)' indicates a requirement only if any element of 'column' is non-missing.
primary_key: logical where TRUE indicates the column is a primary key, other values may be FALSE or missing
references: Reference to other columns in the data model. Either 1) a cross-table reference string following the DBML format, or 2) 'from:' followed by a comma-separated list of columns used to automatically generate this column using a hash function.
description: Note string (column description) following the DBML format
dm
object
json <- system.file("extdata", "data_model.json", package="AnvilDataModels")
(dm <- json_to_dm(json))
attr(dm, "required")
lapply(dm, attr, "required")
tmp <- tempfile()
json_to_dbml(json, tmp)
readLines(tmp, n=14)
unlink(tmp)
json <- system.file("extdata", "data_model_conditional.json", package="AnvilDataModels")
(dm <- json_to_dm(json))
attr(dm, "conditions")
lapply(dm, attr, "conditions")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.