Covert string into dictionary

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

Hi!
I have a string which is like this "{"apple" : 20, "mango" : 25}" and I want to convert it into the dictionary as the dictionary is clearly visible in it

:bust_in_silhouette: Reply From: gioele

You are trying to parse a JSON string into a dictionary.
When looking for an answer always pay attention to the right words, it will help you a lot with your programming.

If you check this thread
https://forum.godotengine.org/8291/how-to-parse-a-json-file-i-wrote-myself

I think the most voted answer (the one for Godot 3) is the one that suits you.

First of all Sorry for repeating question just i was not getting right words.
Actually I was doing this

var dict = {"apple" : 20, "mango" : 25}
var string_of_dict = str(dict)
#now I want it to convert into dictionary again

Help me please | 2021-07-28 12:11

Downvote for talking around and not giving the right answer or example.
And the question contains the right words.

Losatu | 2021-09-22 12:50

User was directed to an existing good answer with explanation of the right words to use to describe the problem. User chose the answer as suitable. Maybe I talked around too much but the problem was solved when it was raised.

gioele | 2021-09-22 13:28

:bust_in_silhouette: Reply From: Losatu
parse_json(my_string)

or

JSON.parse(my_string).result

should create a dictionary

Thank you for a short and sweet answer that doesn’t waste anybody’s time and let’s them continue being productive in Godot.

gothrond | 2023-01-27 02:04