diff options
Diffstat (limited to 'docs/guides/runtime/import-json.md')
-rw-r--r-- | docs/guides/runtime/import-json.md | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/guides/runtime/import-json.md b/docs/guides/runtime/import-json.md new file mode 100644 index 000000000..3db2daaea --- /dev/null +++ b/docs/guides/runtime/import-json.md @@ -0,0 +1,32 @@ +--- +name: Import a JSON file +--- + +Bun natively supports `.json` imports. + +```json#package.json +{ + "name": "bun", + "version": "1.0.0", + "author": { + "name": "John Dough", + "email": "john@dough.com" + } +} +``` + +--- + +Import the file like any other source file. + +```ts +import data from "./package.json"; + +data.name; // => "bun" +data.version; // => "1.0.0" +data.author.name; // => "John Dough" +``` + +--- + +See [Docs > Runtime > TypeScript](/docs/runtime/typescript) for more information on using TypeScript with Bun. |