JSON 模块


\JSON modules

版本历史
版本变更
v20.18.3

JSON 模块不再是实验性的。

稳定性: 2 - 稳定的

\Stability: 2 - Stable

import 可以引用 JSON 文件:

\JSON files can be referenced by import:

import packageConfig from './package.json' with { type: 'json' }; 

with { type: 'json' } 语法是强制性的;见 导入属性

\The with { type: 'json' } syntax is mandatory; see Import Attributes.

导入的 JSON 只暴露一个 default 导出。不支持命名导出。在 CommonJS 缓存中创建缓存条目,以避免重复。如果 JSON 模块已经从同一路径导入,则在 CommonJS 中返回相同的对象。

\The imported JSON only exposes a default export. There is no support for named exports. A cache entry is created in the CommonJS cache to avoid duplication. The same object is returned in CommonJS if the JSON module has already been imported from the same path.

AltStyle によって変換されたページ (->オリジナル) /