+2 votes

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

Godot version v3.2.3-stable_win64
in Engine by (942 points)

2 Answers

–3 votes
Best answer

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

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

by (291 points)
selected by

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

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

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.

+2 votes



should create a dictionary

by (49 points)
edited by

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

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 Frequently asked questions and 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 [email protected] with your username.