연구 설문조사: Blockly 사용 경험을 알려주세요
설문조사 시작
직렬화
직렬화는 작업공간 상태를 로드할 수 있도록 저장합니다.
나중에 작업공간으로 돌아갈 수도 있습니다 저장해야 하는 모든 데이터를
텍스트 기반 형식으로 간편하게
저장할 수 있습니다
작업공간을 JSON으로 직렬화하는 것이 좋습니다.
자세한 내용은 직렬화를 참고하세요.
저장
다음 코드 스니펫은 작업공간의 상태를
저장할 JSON:
// Serialize the state.
const state = Blockly.serialization.workspaces.save(myWorkspace);
// Then you save the state, e.g. to local storage.
localStorage.setItem('workspace-state', state);
로드
다음 코드 스니펫은 저장된 상태를 워크스페이스에 로드하는 방법을 보여줍니다.
// Get your saved state from somewhere, e.g. local storage.
const state = localStorage.getItem('workspace-state');
// Deserialize the state.
Blockly.serialization.workspaces.load(state, myWorkspace);
이렇게 하면
살펴보겠습니다
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-11-04(UTC)
[null,null,["최종 업데이트: 2024-11-04(UTC)"],[[["Serialization allows you to save the current state of your Blockly workspace (blocks, variables, etc.) into a text-based format, typically JSON, for later retrieval."],["You can save the serialized workspace data to a storage location like local storage and then load it back into a workspace to restore its previous state."],["Blockly provides APIs (`Blockly.serialization.workspaces.save` and `Blockly.serialization.workspaces.load`) for easily serializing and deserializing workspace states."]]],["Serialization saves workspace states for later loading by converting data into a text-based format, preferably JSON. To save, use `Blockly.serialization.workspaces.save(myWorkspace)` to get the state, then store it (e.g., in local storage). To load, retrieve the saved state and use `Blockly.serialization.workspaces.load(state, myWorkspace)` to recreate blocks, variables, and other elements in the workspace.\n"]]