JS_godot_singleton
user_8809051
plain_text
10 months ago
779 B
11
Indexable
Never
extends Node var window func _init(): window = JavaScript.get_interface("window") func js_typeof(value): return window.typeOf(value) func js_object_to_dict(data): if data == null: return null var keys = object.keys(data) var length = keys.length var result = {} for i in range(length): match js_typeof(data[keys[i]]): "array": result[keys[i]] = js_array_to_array(data[keys[i]]) "object": result[keys[i]] = js_object_to_dict(data[keys[i]]) "null": continue "function":continue _: result[keys[i]] = data[keys[i]] return result func js_array_to_array(js_array): if js_array == null: return null var a = [] var l = js_array.length for j in range(l): a.append(js_array[j]) return a
Leave a Comment