-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictexample json.py
More file actions
81 lines (79 loc) · 1.67 KB
/
Copy pathdictexample json.py
File metadata and controls
81 lines (79 loc) · 1.67 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import json
j_i = {
"colors": [
{
"color": "black",
"category": "hue",
"type": "primary",
"code": {
"rgba": [255,255,255,1],
"hex": "#000"
}
},
{
"color": "white",
"category": "value",
"code": {
"rgba": [0,0,0,1],
"hex": "#FFF"
}
},
{
"color": "red",
"category": "hue",
"type": "primary",
"code": {
"rgba": [255,0,0,1],
"hex": "#FF0"
}
},
{
"color": "blue",
"category": "hue",
"type": "primary",
"code": {
"rgba": [0,0,255,1],
"hex": "#00F"
}
},
{
"color": "yellow",
"category": "hue",
"type": "primary",
"code": {
"rgba": [255,255,0,1],
"hex": "#FF0"
}
},
{
"color": "green",
"category": "hue",
"type": "secondary",
"code": {
"rgba": [0,255,0,1],
"hex": "#0F0"
}
},
]
}
print ( j_i['colors']['color'])
for y,x in j_i.items():
print (y, "=>", type( x ) )
for i in range (len(x) ) :
print ( '----------')
# print (x[i], type(x[i]))
if type(x[i]) == dict:
for k,v in x[i].items():
print (k,'===>',v)
##Jason example 3
#with open('JsonMoviesInputXy.txt', 'w') as outfile:
# json.dump(j_i, outfile)
#with open('JsonMoviesInputX.json', 'w') as outfile:
# json.dump(j_i, outfile)
#
#
#with open('JsonMoviesInputX.json') as json_data:
# d = json.load(json_data)
# print(d)
# for key,val in d.items():
# print (key, "=>", val)