Bun can parse JSON files directly.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/zhcndoc/bun/llms.txt
Use this file to discover all available pages before exploring further.
Powered by Mintlify
Auto-generate your docs
Parse JSON files with Bun
Bun can parse JSON files directly.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/zhcndoc/bun/llms.txt
Use this file to discover all available pages before exploring further.
const file = Bun.file("data.json");
const data = await file.json();
console.log(data);
interface User {
name: string;
email: string;
}
const file = Bun.file("users.json");
const users: User[] = await file.json();
try {
const file = Bun.file("config.json");
const config = await file.json();
} catch (error) {
console.error("Invalid JSON:", error);
}