forked from johncorderox/Iterating-JSON-APIs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.rb
105 lines (93 loc) · 2.39 KB
/
test.rb
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
require 'json'
json = JSON.parse'{
"type": "item",
"version": "1.7.20",
"data":{
"1002":{
"generic_name": "ACETAMINOPHEN",
"brand_name": "Tylenol",
"film_coated": true,
"dosage": [
200,
400,
500,
1000
],
"purpose": "pain reliever/fever reducer",
"uses": [
"headache",
"muscular aches",
"backache",
"minor pain of arthritis",
"the common cold",
"toothache",
"premenstrual and menstrual cramps",
"temporarily reduces fever"
],
"image": {
"full": "tylenol.png",
"small": "tylenol_small.png",
"x":0,
"y":0,
"w":100,
"h":100
},
"tags": [
"pain",
"OTC",
"cramps"
],
"purpose": "treat motion sickness",
"uses": [
"vomiting",
"motion sickness",
"nausea"
],
"image": {
"full": "dramamine.png",
"small": "dramamine_small.png",
"x":0,
"y":0,
"w":250,
"h":250
}
},
"1003":{
"generic_name": "MECLIZINE",
"brand_name": "Dramamine",
"film_coated": false,
"dosage": [
25,
50
],
"purpose": "treat motion sicknessx",
"uses": [
"vomiting",
"motion sickness",
"nausea"
],
"image": {
"full": "dramamine.png",
"small": "dramamine_small.png",
"x":0,
"y":0,
"w":250,
"h":250
},
"tags": [
"motion sickness",
"OTC",
"vertigo"
]
}
},
"meta": {
"total_count": 2,
"call_type": "GET"
}
}'
json['data'].each do |x|
x.each do |y|
puts y['generic_name']
end
end