MCPcopy Create free account
hub / github.com/esengine/esengine / JsonLoader

Class JsonLoader

packages/asset-system/src/loaders/JsonLoader.ts:14–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12 * JSON加载器实现
13 */
14export class JsonLoader implements IAssetLoader<IJsonAsset> {
15 readonly supportedType = AssetType.Json;
16 readonly supportedExtensions = ['.json', '.jsonc'];
17 readonly contentType: AssetContentType = 'text';
18
19 /**
20 * Parse JSON from text content.
21 * 从文本内容解析JSON。
22 */
23 async parse(content: IAssetContent, _context: IAssetParseContext): Promise<IJsonAsset> {
24 if (!content.text) {
25 throw new Error('JSON content is empty');
26 }
27
28 return {
29 data: JSON.parse(content.text)
30 };
31 }
32
33 /**
34 * Dispose loaded asset
35 * 释放已加载的资产
36 */
37 dispose(asset: IJsonAsset): void {
38 // 清空 JSON 数据 | Clear JSON data
39 asset.data = null;
40 }
41}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected