I am trying to access a JSON file that I converted to a dictionary from a different scene what do I do

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Linc_T_G

Here is the function that tries to access the dictionary:

remote func Get_Player_Level():
	var sender_id = get_tree().get_rpc_sender_id()
	var s_data = Json_Reader.Player_Data[Player].Level
	rpc_id(sender_id, "Returned_data", s_data)

And here is the code that translates the JSON file to a dictionary:

extends Node

var Player_Data

func _ready():
	var Player_data_file = File.new()
	Player_data_file.open("res://Assets/Data/Player_Data.json", File.READ)
	var Player_data_to_json = JSON.parse(Player_data_file.get_as_text())
	Player_Data = Player_data_to_json.result

I get the error :

The Identifier “Player” isn’t declared in the current scope.

:bust_in_silhouette: Reply From: jgodfrey

You’re referencing a Player variable here (as the array index):

var s_data = Json_Reader.Player_Data[Player].Level

I assume that’s undefined. Just a guess, but perhaps you meant that to be the string “Player”?

If that really is supposed to be a variable reference, it needs to be defined…