Need help in JSON

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

I’m creating a 4 Pics 1 Word-like game, now I’m having problems on how to show the images in TextureRect that stored in my JSON file. Here’s the format of my json file.

{
"1": {
    "gold" : 5,
    "pictures" : [ "res://icon.png", "res://icon1.png", "res://icon2.png", "res://icon3.png" ],
    "letters" : [ "T", "E", "S", "T" ]
},
"2": {
    "gold" : 5,
    "pictures" : [ "res://icon.png", "res://icon1.png", "res://icon2.png", "res://icon3.png" ],
    "letters" : [ "B", "E", "S", "T" ]
},
"3": {
    "gold" : 5,
    "pictures" : [ "res://icon.png", "res://icon1.png", "res://icon2.png", "res://icon3.png" ],
    "letters" : [ "W", "E", "S", "T" ]
}
}
:bust_in_silhouette: Reply From: sprite-1

Something like this?

# Load the JSON file
var f := File.new()
f.open("res://my_json.json",File.READ)
var json_text := f.get_as_text()
var json_data:Dictionary = JSON.parse(json_text).result
f.close()

# Print out the image set array for the specific ID
print(json_data["1"].pictures)

It’s hard to tell what exactly you want with a vague question

Hi, thank you for your reply, I got this error:

Invalid get index 'pictures' (on base: 'Dictionary').

Jedzkie | 2019-10-09 11:11

What does print(json_data) show?`

sprite-1 | 2019-10-09 20:41