Skip to contents

Converts the raw JSON written to stdout by scc --format json into a tibble::tibble(). Handles empty or blank output by returning a zero-row tibble with the correct column schema via empty_scc_tibble().

Usage

parse_scc_json(json_text, by_file = FALSE, dryness = FALSE)

Arguments

json_text

Character scalar: raw stdout captured from scc.

by_file

Logical. When TRUE unpacks the per-file Files array inside each language block; when FALSE (default) returns one row per language.

dryness

Logical. When TRUE the returned tibble includes a dryness column (uloc / lines); when FALSE (default) the column is omitted.

Value

A tibble::tibble(). Column layout matches scc() when by_file = FALSE and scc_by_file() when by_file = TRUE.

Examples

if (FALSE) { # \dontrun{
json <- processx::run("scc", c("--format", "json", "."))$stdout
parse_scc_json(json)

json_by_file <- processx::run("scc", c("--format", "json", "--by-file", "."))$stdout
parse_scc_json(json_by_file, by_file = TRUE)
} # }