vanilladocs
vanillapunch.com
API / resource/jsonasset

resource/jsonasset

JSON 데이터 애셋.

JSON data asset.

JsonAssetextends TextAsset

짝Counterpart: vanilla-engine JsonAsset

JSON 데이터 애셋.

JSON data asset.

예제ExampleJSON 파일 읽고 항목 보기Load a JSON file and read entries
import { JsonAsset } from "./build/vanilla.js";

const jsonAsset = new JsonAsset();
await jsonAsset.load("examples/timelineshowcase/assets/combo.timeline.json");
if (jsonAsset.isLoaded()) {
	const timelineKeys = Object.keys(jsonAsset.data);
	console.log(timelineKeys.length, jsonAsset.data.name);
}
생성자constructorconstructor()#0.0.8 부터since 0.0.8소스source

생성.

Constructor.

짝Counterpart: vanilla-engine JsonAsset.new

필드fielddata#0.0.8 부터since 0.0.8소스source

해석한 JSON 값. (읽기 전이나 해석이 실패하면 null)

Parsed JSON value. (null before loading or if parsing failed)

반환ReturnsSystem.Object | null

짝Counterpart: vanilla-engine JsonAsset.get_data

메서드methodasync load(assetPath)#0.0.8 부터since 0.0.8소스source

비동기 애셋 로드.

Loads the asset asynchronously.

assetPathstring
JSON 파일 경로. (이미 읽혔으면 아무것도 하지 않는다)JSON file path. (does nothing if already loaded)

반환ReturnsPromise<void> 다 읽고 해석하면 풀리는 프로미스. (받기나 해석이 실패하면 console.error 로 알리고 읽히지 않은 채로 거부된다)A promise resolved once fetched and parsed. (if fetching or parsing fails, it reports with console.error and rejects, staying not loaded)

짝Counterpart: vanilla-engine JsonAsset.load

메서드methodloadFromBytes(assetPath, bytes)#0.4.0 부터since 0.4.0소스source

이미 가진 바이트로 읽기. (UTF-8 JSON, 해석하지 못하면 알리고 읽히지 않은 것으로 둔다. load 와 같다)

Loads from bytes already held. (UTF-8 JSON, if it cannot be parsed, reports it and leaves it unloaded. Same as load)

assetPathstring
getAssetPath 에 쓸 이름.Name used for getAssetPath.
bytesArrayBuffer | ArrayBufferView
JSON 파일의 바이트. (UTF-8)Bytes of the JSON file. (UTF-8)

짝Counterpart: vanilla-engine JsonAsset.load_from_bytes

메서드methodunload()#0.0.8 부터since 0.0.8소스source

애셋 언로드.

Unloads the asset.

짝Counterpart: vanilla-engine JsonAsset.unload