Skip to contents

The studio guide for mascot_check_character(). The same page is read in the mascot studio.

Try it live. The mascot studio shows this function with live controls and the generated code. In an R session with the optional packages bslib and knitr installed, run:
mascot::mascot_studio(fn = "mascot_check_character")
It opens on this function's guide; change a control and watch the mascot.
Experimental Its arguments, results and diagnostics may change in a later release. What the file format accepts may grow; version-1 files keep loading.

Check a character you wrote as a list

mascot_check_character() checks JSON text or a plain R list that describes a character, for example one you read with jsonlite::read_json() or wrote by hand. It returns a checked character, or an error that names the first problem. The package’s example file gives a list that passes:

path <- system.file("examples", "characters", "study_bot.json", package = "mascot")
source <- jsonlite::read_json(path)
bot <- mascot::mascot_check_character(source)

A list that leaves out what a character needs is refused, and the error says where:

mascot::mascot_check_character(list(format_version = 1))

Error: $.id: Supply this required field.

mascot_read_character() reads and checks a file in one step. The studio takes the built-in characters only.

Warnings, errors and common mistakes

mascot_check_character(list(format_version = 1))
Error: could not find function "mascot_check_character"