GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • Guides
  • Reference
  • Blog
  • Install
  • Home
  • Package Manager
  • Bundler
  • Compiler
  • Test Runner
  • Linter
  • Formatter
  • Feedback
  • Deploy on Vercel

This view

  • Original page
  • New address

GeezerVison is showing bun.com — Import a JSON file | Bun Guides

Guides

Bun natively supports .json imports.

package.json
{
  "name": "bun",
  "version": "1.0.0",
  "author": {
    "name": "John Dough",
    "email": "[email protected]"
  }
}

Import the file like any other source file.

data.ts
import data from "./package.json";

data.name; // => "bun"
data.version; // => "1.0.0"
data.author.name; // => "John Dough"

Bun also supports Import Attributes and JSON modules syntax.

data.ts
import data from "./package.json" with { type: "json" };

data.name; // => "bun"
data.version; // => "1.0.0"
data.author.name; // => "John Dough"

See TypeScript for more on using TypeScript with Bun.

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.