title | c3p | hasDemo | deprecated | preview | tags | date | |||||
---|---|---|---|---|---|---|---|---|---|---|---|
How to use JSON in JavaScript |
how-to-use-json-in-javascript-20.05.26.c3p |
true |
true |
preview.png |
|
|
{#if !isSvelte}
- c3p how-to-use-json-in-javascript-20.05.26.c3p
- demo link
- Patreon link
{/if}
runOnStartup(async runtime => { globalThis.g_runtime = runtime })
let json = null;
let jsonObj = null;
function json_initialize(json_name) {
json = g_runtime.objects[json_name].getFirstInstance();
jsonObj = json.getJsonDataCopy();
}
function json_getKey(json_key){
const result = jsonObj[json_key];
return JSON.stringify(result);
}
function json_changeKey(key, value) {
jsonObj[key] = value
json.setJsonDataCopy(jsonObj);
}