Untitled
func _on_get_entries_completed(success, entry): if success: entries = entry else: print("Failed to get entries") return js_object_to_dict(entries) func js_object_to_dict(data): if typeof(data) == TYPE_DICTIONARY: var keys = data.keys() print("keys:", keys) var length = keys.size() print("length:", length) if length == 0: return null var result = {} for i in range(length): if typeof(data[keys[i]]) < 5: result[keys[i]] = data[keys[i]] else: result[keys[i]] = js_array_to_array(data[keys[i]]) print("result:", result) return result elif typeof(data) == TYPE_OBJECT and "id" in data: # Обработка JavaScriptObject с полем id result = {"id": data.id} print("result:", result) return result else: print("Unsupported data type:", typeof(data)) return null func js_array_to_array(js_array): print("is array") var a = [] var l = js_array.size() for j in range(l): a.append(js_array[j]) print("a:", a) return a
Leave a Comment