· 4 years ago · Sep 08, 2021, 02:16 PM
1
2function getData(){
3 // url = 'http://45.129.227.22/api/v1/index';
4 var data;
5 var api = []
6
7 // fetch(url)
8 // .then(function(response) {
9 // data = response.json();
10 // })
11 // .catch(function(response) {
12 // console.error('There was an error', response);
13 // })
14
15 let text = `[
16 {
17 "AO": [
18 {
19 "index": "43.35",
20 "year": 2021,
21 "country": "AO"
22 },
23 [
24 {
25 "pillar": "infrastructure",
26 "weight": "0.25",
27 "value": "42.21"
28 },
29 {
30 "pillar": "performance",
31 "weight": "0.25",
32 "value": "46.90"
33 },
34 {
35 "pillar": "security",
36 "weight": "0.25",
37 "value": "42.44"
38 },
39 {
40 "pillar": "market_readiness",
41 "weight": "0.25",
42 "value": "41.87"
43 }
44 ],
45 [
46 {
47 "dimension": "cable_ecosystem",
48 "weight": "0.40",
49 "value": "15.74",
50 "pillar": "infrastructure"
51 },
52 {
53 "dimension": "mobile_connectivity",
54 "weight": "0.30",
55 "value": "58.96",
56 "pillar": "infrastructure"
57 },
58 {
59 "dimension": "enabling_infrastructure",
60 "weight": "0.30",
61 "value": "60.75",
62 "pillar": "infrastructure"
63 },
64 {
65 "dimension": "fixed_networks",
66 "weight": "0.40",
67 "value": "61.97",
68 "pillar": "performance"
69 },
70 {
71 "dimension": "mobile_networks",
72 "weight": "0.60",
73 "value": "36.86",
74 "pillar": "performance"
75 },
76 {
77 "dimension": "enabling_technologies",
78 "weight": "0.20",
79 "value": "64.77",
80 "pillar": "security"
81 },
82 {
83 "dimension": "dns_ecosystem",
84 "weight": "0.30",
85 "value": "13.40",
86 "pillar": "security"
87 },
88 {
89 "dimension": "routing_hygiene",
90 "weight": "0.30",
91 "value": "66.14",
92 "pillar": "security"
93 },
94 {
95 "dimension": "security_threat",
96 "weight": "0.20",
97 "value": "28.12",
98 "pillar": "security"
99 },
100 {
101 "dimension": "market_structure",
102 "weight": "0.50",
103 "value": "49.79",
104 "pillar": "market_readiness"
105 },
106 {
107 "dimension": "traffic_localization",
108 "weight": "0.50",
109 "value": "33.95",
110 "pillar": "market_readiness"
111 }
112 ],
113 [
114 {
115 "indicator": "affordability",
116 "weight": "0.40",
117 "value": "78.48",
118 "dimension": "market_structure"
119 },
120 {
121 "indicator": "as_hegemony",
122 "weight": "0.30",
123 "value": "13.24",
124 "dimension": "market_structure"
125 },
126 {
127 "indicator": "datacenters",
128 "weight": "0.30",
129 "value": "100.00",
130 "dimension": "enabling_infrastructure"
131 },
132 {
133 "indicator": "ddos_potential",
134 "weight": "0.20",
135 "value": "0.00",
136 "dimension": "security_threat"
137 },
138 {
139 "indicator": "dnssec",
140 "weight": "0.50",
141 "value": "0.00",
142 "dimension": "dns_ecosystem"
143 },
144 {
145 "indicator": "dnssec_validation",
146 "weight": "0.50",
147 "value": "26.80",
148 "dimension": "dns_ecosystem"
149 },
150 {
151 "indicator": "domain_count",
152 "weight": "0.30",
153 "value": "7.93",
154 "dimension": "traffic_localization"
155 },
156 {
157 "indicator": "egdi",
158 "weight": "0.30",
159 "value": "47.02",
160 "dimension": "traffic_localization"
161 },
162 {
163 "indicator": "exit_points",
164 "weight": "0.50",
165 "value": "19.36",
166 "dimension": "cable_ecosystem"
167 },
168 {
169 "indicator": "fibre_10km_reach",
170 "weight": "0.50",
171 "value": "12.12",
172 "dimension": "cable_ecosystem"
173 },
174 {
175 "indicator": "fixed_download",
176 "weight": "0.40",
177 "value": "68.13",
178 "dimension": "fixed_networks"
179 },
180 {
181 "indicator": "fixed_latency",
182 "weight": "0.30",
183 "value": "67.43",
184 "dimension": "fixed_networks"
185 },
186 {
187 "indicator": "fixed_upload",
188 "weight": "0.30",
189 "value": "48.29",
190 "dimension": "fixed_networks"
191 },
192 {
193 "indicator": "global_cybersecurity_index",
194 "weight": "0.30",
195 "value": "12.08",
196 "dimension": "security_threat"
197 },
198 {
199 "indicator": "https",
200 "weight": "0.70",
201 "value": "91.66",
202 "dimension": "enabling_technologies"
203 },
204 {
205 "indicator": "ipv6",
206 "weight": "0.30",
207 "value": "2.04",
208 "dimension": "enabling_technologies"
209 },
210 {
211 "indicator": "manrs",
212 "weight": "1.00",
213 "value": "66.14",
214 "dimension": "routing_hygiene"
215 },
216 {
217 "indicator": "market_concentration",
218 "weight": "0.30",
219 "value": "48.07",
220 "dimension": "market_structure"
221 },
222 {
223 "indicator": "mobile_download",
224 "weight": "0.40",
225 "value": "42.26",
226 "dimension": "mobile_networks"
227 },
228 {
229 "indicator": "mobile_latency",
230 "weight": "0.30",
231 "value": "17.48",
232 "dimension": "mobile_networks"
233 },
234 {
235 "indicator": "mobile_upload",
236 "weight": "0.30",
237 "value": "49.02",
238 "dimension": "mobile_networks"
239 },
240 {
241 "indicator": "network_coverage",
242 "weight": "0.70",
243 "value": "53.61",
244 "dimension": "mobile_connectivity"
245 },
246 {
247 "indicator": "number_of_ixps",
248 "weight": "0.20",
249 "value": "30.81",
250 "dimension": "enabling_infrastructure"
251 },
252 {
253 "indicator": "peering_efficiency",
254 "weight": "0.40",
255 "value": "43.66",
256 "dimension": "traffic_localization"
257 },
258 {
259 "indicator": "power_availability",
260 "weight": "0.40",
261 "value": "61.48",
262 "dimension": "enabling_infrastructure"
263 },
264 {
265 "indicator": "secure_internet_servers",
266 "weight": "0.30",
267 "value": "28.31",
268 "dimension": "security_threat"
269 },
270 {
271 "indicator": "spam_infections",
272 "weight": "0.20",
273 "value": "80.00",
274 "dimension": "security_threat"
275 },
276 {
277 "indicator": "spectrum_allocation",
278 "weight": "0.30",
279 "value": "71.44",
280 "dimension": "mobile_connectivity"
281 }
282 ]
283 ]
284 },
285 {
286 "BF": [
287 {
288 "index": "39.78",
289 "year": 2021,
290 "country": "BF"
291 },
292 [
293 {
294 "pillar": "infrastructure",
295 "weight": "0.25",
296 "value": "26.20"
297 },
298 {
299 "pillar": "performance",
300 "weight": "0.25",
301 "value": "55.72"
302 },
303 {
304 "pillar": "security",
305 "weight": "0.25",
306 "value": "56.70"
307 },
308 {
309 "pillar": "market_readiness",
310 "weight": "0.25",
311 "value": "20.49"
312 }
313 ],
314 [
315 {
316 "dimension": "cable_ecosystem",
317 "weight": "0.40",
318 "value": "17.35",
319 "pillar": "infrastructure"
320 },
321 {
322 "dimension": "mobile_connectivity",
323 "weight": "0.30",
324 "value": "27.65",
325 "pillar": "infrastructure"
326 },
327 {
328 "dimension": "enabling_infrastructure",
329 "weight": "0.30",
330 "value": "36.54",
331 "pillar": "infrastructure"
332 },
333 {
334 "dimension": "fixed_networks",
335 "weight": "0.40",
336 "value": "47.51",
337 "pillar": "performance"
338 },
339 {
340 "dimension": "mobile_networks",
341 "weight": "0.60",
342 "value": "61.19",
343 "pillar": "performance"
344 },
345 {
346 "dimension": "enabling_technologies",
347 "weight": "0.20",
348 "value": "57.54",
349 "pillar": "security"
350 },
351 {
352 "dimension": "dns_ecosystem",
353 "weight": "0.30",
354 "value": "41.24",
355 "pillar": "security"
356 },
357 {
358 "dimension": "routing_hygiene",
359 "weight": "0.30",
360 "value": "73.82",
361 "pillar": "security"
362 },
363 {
364 "dimension": "security_threat",
365 "weight": "0.20",
366 "value": "53.35",
367 "pillar": "security"
368 },
369 {
370 "dimension": "market_structure",
371 "weight": "0.50",
372 "value": "26.97",
373 "pillar": "market_readiness"
374 },
375 {
376 "dimension": "traffic_localization",
377 "weight": "0.50",
378 "value": "14.01",
379 "pillar": "market_readiness"
380 }
381 ],
382 [
383 {
384 "indicator": "affordability",
385 "weight": "0.40",
386 "value": "18.58",
387 "dimension": "market_structure"
388 },
389 {
390 "indicator": "as_hegemony",
391 "weight": "0.30",
392 "value": "27.31",
393 "dimension": "market_structure"
394 },
395 {
396 "indicator": "datacenters",
397 "weight": "0.30",
398 "value": "44.93",
399 "dimension": "enabling_infrastructure"
400 },
401 {
402 "indicator": "ddos_potential",
403 "weight": "0.20",
404 "value": "100.00",
405 "dimension": "security_threat"
406 },
407 {
408 "indicator": "dnssec",
409 "weight": "0.50",
410 "value": "0.00",
411 "dimension": "dns_ecosystem"
412 },
413 {
414 "indicator": "dnssec_validation",
415 "weight": "0.50",
416 "value": "82.47",
417 "dimension": "dns_ecosystem"
418 },
419 {
420 "indicator": "domain_count",
421 "weight": "0.30",
422 "value": "4.26",
423 "dimension": "traffic_localization"
424 },
425 {
426 "indicator": "egdi",
427 "weight": "0.30",
428 "value": "42.45",
429 "dimension": "traffic_localization"
430 },
431 {
432 "indicator": "exit_points",
433 "weight": "0.50",
434 "value": "22.58",
435 "dimension": "cable_ecosystem"
436 },
437 {
438 "indicator": "fibre_10km_reach",
439 "weight": "0.50",
440 "value": "12.12",
441 "dimension": "cable_ecosystem"
442 },
443 {
444 "indicator": "fixed_download",
445 "weight": "0.40",
446 "value": "54.20",
447 "dimension": "fixed_networks"
448 },
449 {
450 "indicator": "fixed_latency",
451 "weight": "0.30",
452 "value": "42.79",
453 "dimension": "fixed_networks"
454 },
455 {
456 "indicator": "fixed_upload",
457 "weight": "0.30",
458 "value": "43.30",
459 "dimension": "fixed_networks"
460 },
461 {
462 "indicator": "global_cybersecurity_index",
463 "weight": "0.30",
464 "value": "40.37",
465 "dimension": "security_threat"
466 },
467 {
468 "indicator": "https",
469 "weight": "0.70",
470 "value": "81.33",
471 "dimension": "enabling_technologies"
472 },
473 {
474 "indicator": "ipv6",
475 "weight": "0.30",
476 "value": "2.04",
477 "dimension": "enabling_technologies"
478 },
479 {
480 "indicator": "manrs",
481 "weight": "1.00",
482 "value": "73.82",
483 "dimension": "routing_hygiene"
484 },
485 {
486 "indicator": "market_concentration",
487 "weight": "0.30",
488 "value": "37.83",
489 "dimension": "market_structure"
490 },
491 {
492 "indicator": "mobile_download",
493 "weight": "0.40",
494 "value": "53.94",
495 "dimension": "mobile_networks"
496 },
497 {
498 "indicator": "mobile_latency",
499 "weight": "0.30",
500 "value": "64.79",
501 "dimension": "mobile_networks"
502 },
503 {
504 "indicator": "mobile_upload",
505 "weight": "0.30",
506 "value": "67.26",
507 "dimension": "mobile_networks"
508 },
509 {
510 "indicator": "network_coverage",
511 "weight": "0.70",
512 "value": "27.06",
513 "dimension": "mobile_connectivity"
514 },
515 {
516 "indicator": "number_of_ixps",
517 "weight": "0.20",
518 "value": "48.49",
519 "dimension": "enabling_infrastructure"
520 },
521 {
522 "indicator": "peering_efficiency",
523 "weight": "0.40",
524 "value": "0.00",
525 "dimension": "traffic_localization"
526 },
527 {
528 "indicator": "power_availability",
529 "weight": "0.40",
530 "value": "33.41",
531 "dimension": "enabling_infrastructure"
532 },
533 {
534 "indicator": "secure_internet_servers",
535 "weight": "0.30",
536 "value": "17.48",
537 "dimension": "security_threat"
538 },
539 {
540 "indicator": "spam_infections",
541 "weight": "0.20",
542 "value": "80.00",
543 "dimension": "security_threat"
544 },
545 {
546 "indicator": "spectrum_allocation",
547 "weight": "0.30",
548 "value": "29.03",
549 "dimension": "mobile_connectivity"
550 }
551 ]
552 ]
553 }
554 ]`
555
556 data = JSON.parse(text)
557
558 for(let i=0; i < data.length; i++){
559 elem = data[i];
560 key = Object.keys(elem)[0];
561 let obj = elem[key]
562 api.push(obj.flat())
563
564 // for(let j=0; j < elem[key].length; j++){
565 // let obj = elem[key]
566 // api.concat(Object.values(obj[j]));
567 // }
568 }
569 console.log(api)
570 return api;
571}
572
573getData()