Skip to contents

This function reads a JSON file containing colour definitions and converts them into a named list structure. Each colour group is unlisted to create a flat structure with named elements.

Usage

load_cols(path = "colours.json")

Arguments

path

Character string specifying the path to the JSON file containing colour definitions. Defaults to "colours.json".

Value

A list where each element represents a colour group from the JSON file, with nested structures flattened into named vectors.

Details

The function uses jsonlite::read_json() to parse the JSON file and then applies unlist() with use.names = TRUE to each element to maintain the naming structure while flattening nested lists.

Examples

if (FALSE) { # \dontrun{
# Load colours from default file
colours <- load_cols()

# Load colours from custom file
colours <- load_cols("my_colours.json")
} # }