0 votes

trying to learn how to work with json, you can write an example of how to output each element from such a json array separately to the list as I look at some complex examples I can not figure it out
first made a photo in the table attached

enter image description here
then attached the photo to json

enter image description here

how can I display it in a loop, for example, in buttons in via gdscript
in 1 button
1 samsung i710 2012

2 button
2 nokia n73 2013
3 button
3 siemens name 2014

in Engine by (22 points)

2 Answers

+1 vote
Best answer
extends Control

var _data := {
    "1" : {
        "name": "russian",
        "model": "i710",
        "year": 2012
    "2" : {
        "name": "nokia",
        "model": "n73",
        "year": 2013
    "3" : {
        "name": "siemens",
        "model": "name",
        "year": 2014

func _ready():
    var json := to_json(_data)
    var dictionary : Dictionary = JSON.parse(json).result
    for key in dictionary:
by (1,667 points)
edited by
0 votes

Once you have your json file you need to parse it. As you parse it you can associate the values of each key to a button with variables or metadata. Then you need to manually connect the button signal "pressed" so you can pass this variable/metadata as an argument and finally a function would print every key of the dictionary in the variable/metadata.

by (396 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.