loadJSON

loadJSON(path) synchronously reads a UTF-8 JSON file and returns its parsed value. Objects, arrays, strings, numbers, booleans, and null are all supported. The example uses a title, axis label, and nested site records to build a bar chart.

Sample input

The example reads survey.json:

Paths and hosts

The CLI resolves relative paths from the JSX file's directory, or from the working directory for stdin. Absolute paths also work. Missing files and invalid JSON throw an error containing the resolved filename.

This is a CLI helper. The docs preview supplies a shim for the bundled sample files; it does not read your computer's filesystem. For CLI use, place the sample file beside your JSX script. The fixtures are checked in to the sample data directory. Paths refer to local files, not remote URLs.

See loadCSV for tables and loadPNG for images.