I face a problem when reading a JSON file from a Python script. Here is the JSON file:
{
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6,
"g": 7,
"h": 8,
"i": 9
}
and this is the Python file on where I open the JSON file from the current path and read every values associated with the letter in it:
with open(os.getcwd() + '/letters.json') as lettersListJSON:
lettersList = json.load(lettersListJSON)
for char in lettersList
print lettersList[char]
I strangely get this output:
1
3
2
5
4
7
6
9
8
Why are these values interlaced and how can I prevent this from happening ? Should I lock the access of the variable with a mutex?