Learn R Programming

justifier (version 0.2.6)

export_to_json: Export a justifier specification to JSON

Description

Export a justifier specification to JSON

Usage

export_to_json(x, file = NULL, wrap_in_html = FALSE)

# S3 method for justifierStructuredObject export_to_json(x, file = NULL, wrap_in_html = FALSE)

# S3 method for justifier_json print(x, ...)

Value

If a file is specified to write, to, x will be returned invisibly to allow building a pipe chain; if file=NULL, the resulting JSON will be returned as a character vector.

Arguments

x

The justifier specification.

file

Optionally, a file to save the JSON to.

wrap_in_html

Whether to wrap the JSON in an HTML element.

...

Any additional arguments are ignored.

Examples

Run this code
### Programmatically create a justification with two assertions
### but without sources; flatten it; and show the json
justifier::justify(
  "Icecream will make me feel less fit",
  assertion = c(
    justifier::assert('Icecream is rich in energy'),
    justifier::assert('Consuming high-energy foods makes me feel less fit')
  ),
  weight = -.5
) |>
  justifier::flatten() |>
  justifier::export_to_json();

Run the code above in your browser using DataLab