I have a data in python that is in this format
d1 = ["id":"hajdgrwe2123", "name":"john law", "age":"95"]
Python has it as data type " class 'str' ".
I am sending the data from python to javascript using eel so I want to convert the data to dictionary in javascript so that I can make the call below
d1["id"] # result should be hajdgrwe2123
I tried converting to json in javascript but it did not work. How can I convert the python class str to dictionary in javascript?
When sending from Python to JS, you need to encode the data as JSON (using
json.dumps()for example).Then, you can parse it to a JS object using:
You can access it's properties using:
or: