Hi everyone - quick addition on getting your dictionary into the Client code when your keys are integers.
I had a list of dict called ‘list_dict_var’
It looked something like:
[{0: ‘Aaron’, 1: ‘Johnson’, 2: ‘a.johnson@example.com’}, {0: ‘A’, 1: ‘Blackhawk’, 2: ‘a.b@example.com’}]
The keys are integers and the values are strings. When I use:
jsonString = json.dumps(list_dict_var)
I get this output which can be sent back to the Client code:
[{“0”: “Aaron”, “1”: “Johnson”, “2”: “a.Johnson@example.com”}, {“0”: “A.J”, “1”: “Johnson”, “2”: “a.j.Johnson@example.com”}]
I wanted to get back to single quotes in my list so I could display the data in a Data Grid. To do this, I used
paylaod = json.loads(jsonString)
This returns:
[{‘0’: ‘Aaron’, ‘1’: 'Johnson, ‘2’: ‘a.j@example.com’}, {‘0’: ‘A.J’, ‘1’: ‘Johnson’, ‘2’: ‘a.j.Johnson@example.com’}]
As you can see, the integers are now strings.
In summary use
a = json.dumps(variable_for_your_list_of_dict)
b = json.loads(a)
b is your list of dictionaries where the keys are now strings.
Hope that helps!