Skip to main content

bud.fs.json

Utilities for working with JSON

Read

Reads a JSON file from the filesystem. Compatible with JSON5.

const result = await bud.fs.json.read(`src/index.json`)

Write

Write a JSON file to the filesystem. Compatible with JSON5.

const result = await bud.fs.json.write(`src/index.json`, {foo: `bar`})

Parse

Parses a JSON string. Compatible with JSON5.

const result = bud.fs.json.parse(`{"foo": "bar"}`)

Stringify

Stringifies a JSON object. Safer than the built-in JSON.stringify with protection against recursive reference errors, etc.

const result = bud.fs.json.stringify({foo: `bar`})