-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdict2json.py
40 lines (28 loc) · 1.79 KB
/
dict2json.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import json
dictio = {'PLAYER': '0',
'OBJECTS': ['Vase', 'Knife', 'Ball'],
'Vase' : ['1', 'There is a blue vase in the room.'],
'Knife' : ['7','You can see a knife in front of you.'],
'Ball' : ['5', 'There is a red tennis ball in front of you.'],
'0': ['You are standing at the end of a corridor. There is a door in front of you.',
['S', '1']],
'1': ['You are standing in what seems to be a living room.', ['E','2'],['N','0']],
'2': ['You are standing in what seems to be a hall way connecting many room.', ['W','1'],
['N', '3'], ['E', '5'], ['S', '6']],
'3': ['Your are standing in what seems to be a bedroom. It has got a balcony attached.',
['E', '4'], ['S', '2']],
'4': ['You are standing in the balcony of Room number 3.', ['W', '3']],
'5': ['You are standing in the balcony attached to the hallway.', ['W', '2']],
'6': ['You are standing in a connecting hallway. Three doors await you.', ['N', '2'],
['S', '9'], ['E', '7'], ['W', '8']],
'7': ['You are standing in a kitchen. Utensils everywhere.', ['W', '6']],
'8': ['You are standing in another bedroom. You can see a door that seems to lead to a balcony number 2.', ['E', '6'], ['S', '10']],
'9': ['You are standing in another bedroom. You can see a door that seems to lead to a balcony number 3.', ['N', '6'], ['S', '11']],
'10': ['You are standing in the balcony of room number 8.', ['N', '8']],
'11': ['You are standing in the balcony of room number 9.', ['N', '9']]
}
dumped_dictio = json.dumps(dictio)
loaded_dictio = json.loads(dumped_dictio)
with open('maps.json', 'w') as outfile:
json.dump(loaded_dictio, outfile)
outfile.close()