首页 技术 正文
技术 2022年11月15日
0 收藏 755 点赞 5,076 浏览 4840 个字
{
"data": {
"BTC": [
14781.51,
14888.9,
14900.04,
15098.88,
15308,
14880.01,
14903.13,
14971.9,
15085,
14955,
14789,
15067.99,
15904.57
],
"ETH": [
865,
872.4,
863.31,
876.97,
882.86,
862.34,
872.8,
873.99,
880.66,
881.33,
920,
927.07,
1205.1
],
"LTC": [
253.31,
256.01,
250.74,
252.18,
254.03,
246,
248.99,
250.44,
250.19,
245.51,
245.47,
246.29,
268.77
],
"REP": [
77,
75.51000902,
77.40777699,
77.5,
74.24999999,
75.89999204,
76.56242205,
75.23267389,
75,
74.53486201,
75.89956063,
75.1
],
"ZEC": [
546.0546,
545,
560,
558.21460001,
541.028181,
545.600012,
549.00000003,
552.00000003,
550.24500013,
550,
549.99,
549.99999999
],
"XMR": [
363.89972768,
363.80792688,
374.02733624,
371.73386644,
371.02271409,
375.5,
376.6059407,
378.00000004,
378,
379,
384.5,
387.62246001
],
"ETC": [
31.57099992,
31.1,
31.6652654,
31.69230656,
31,
31.14,
31.88,
31.94201499,
31.17,
31.7,
31.8810021,
31.94147215
],
"XRP": [
2.19000001,
2.2302,
2.34403988,
2.38545257,
2.39000012,
2.40001004,
2.47,
2.57652,
2.76396723,
2.80014755,
2.749,
2.74499994
],
"DASH": [
1144.68252953,
1124.05293517,
1142.00000001,
1140,
1100.2,
1126.92937,
1127.30001,
1115.99999981,
1117,
1103.49,
1129.99999999,
1129.02030677
],
"STR": [
0.63000001,
0.62231267,
0.622,
0.66999999,
0.73,
0.7249,
0.75489999,
0.81299991,
0.8735,
0.913,
0.84290446,
0.84010015
],
"LSK": [
21.4871988962,
20.9578311135,
20.9569305729,
20.8209489423,
20.8218494829,
21.311593479200003,
21.0165163426,
20.950926968900003,
20.2992357547,
20.8625239,
20.7895801114,
20.5769024397
],
"MAID": [
1.1267263807,
1.0934063784999999,
1.0714932239000001,
1.0818494408000001,
1.1231242183,
1.1282272817,
1.145187463,
1.1472887244,
1.1381332283,
1.1576449413,
1.178207285,
1.1643989958
],
"FCT": [
62.37744556,
59.51822915500001,
59.15230949120001,
60.5799665224,
66.3129580721,
65.9176207487,
63.037842,
62.319961051700005,
63.797598086200004,
70.73836467059999,
66.0300382336,
66.39986024
],
"XEM": [
1.2056737733,
1.188713592,
1.2031222416,
1.244246929,
1.26075684,
1.247248731,
1.2840208055000002,
1.3385035118,
1.394337029,
1.523414515,
1.6688518219,
1.6344811890000002
],
"STEEM": [
6.66071924,
7.923895699999999,
7.653423399999999,
7.65408,
7.410190620000001,
7.49273462,
8.807754339999999,
8.90186388,
8.36078796,
8.29410554,
8.0668,
8.25830208
],
"DOGE": [
0.009005406,
0.0091554961,
0.009005406,
0.008855315899999999,
0.008855315899999999,
0.009005406,
0.0091554961,
0.009005406,
0.009005406,
0.0091554961,
0.009005406,
0.0091554961
],
"BTS": [
0.8089856390000001,
0.7813690606,
0.7773166279,
0.7924757280000001,
0.8098861796,
0.8013310439000001,
0.799980233,
0.866019877,
0.8256456401,
0.8966382574,
0.8657196967999999,
0.8732242018
],
"GAME": [
4.6837116606,
4.4972997564,
4.1582462205,
4.2416963161,
4.4798893048,
4.3992909211,
4.6256267919,
4.5067554327,
4.3965892993,
4.5235655239,
4.533921740799999,
4.42765795
],
"ARDR": [
2.2363424899999997,
2.1932666313,
2.1105669862,
2.087753291,
2.1513914934,
2.1066646436,
2.0991601386000003,
2.0565345502000003,
2.0383736481,
2.0997604990000003,
2.0888039217000003,
2.0835507682
],
"DCR": [
107.4643615099,
105.2259177585,
105.9654116812,
105.11740261620001,
101.75928671880001,
102.2154105327,
103.41207890000001,
102.7333714678,
102.2113581,
103.48817458069999,
105.3126698363,
107.4645116
],
"STORJ": [
2.2286878949,
2.1901147392,
2.2259862730999997,
2.1787078916000002,
2.1314295101000003,
2.1668507737000002,
2.2608071763,
2.1971689739,
2.1841111352,
2.2057241095999998,
2.2444473554,
2.2355920394999997
],
"SC": [
0.0286672091,
0.0286672091,
0.028517119,
0.028517119,
0.028817299199999997,
0.028967389300000004,
0.029717839800000003,
0.0298679299,
0.0298679299,
0.031518921,
0.031669011100000005,
0.0321192814
],
"GNT": [
1.1639487255,
1.1424858411999999,
1.1454876432,
1.0842508824000001,
1.0693919625,
1.0812490804,
1.1192218757,
1.0862020537000001,
1.0608368268,
1.1139687222,
1.0608368268,
1.0803485398
],
"BCH": [
2566.54071,
2584.8886243645998,
2757.6337743289,
2613.9844907902,
2599.0776921483,
2619.072245,
2628.4683355303,
2584.1908554897004,
2588.8888257097997,
2588.1469303455,
2541.819369629,
2555.64416874
],
"ZRX": [
0.8702223997999999,
0.8775768147,
0.9203524932,
0.8655696067,
0.8378029382,
0.9072946545,
0.8778769948999999,
0.9238045655000001,
0.9698822262000001,
1.0422256544,
1.0024517779,
1.0017013274
]
}
}

一个jsonObject里面放了一个jsonArray 且这个jsonArray中 每个json对象是一个jsonArray

注:下面就是一个json对像

    "ZRX": [
0.8702223997999999,
0.8775768147,
0.9203524932,
0.8655696067,
0.8378029382,
0.9072946545,
0.8778769948999999,
0.9238045655000001,
0.9698822262000001,
1.0422256544,
1.0024517779,
1.0017013274
]

我们的目标是取出每个json对象的Key值,即这里的”ZRX”;并且,取出每个jsonArray中的第一个数字参数;

实现如下:

   needle.get('https://api.lionshare.capital/api/prices', function(error, response) {
//get方法获取json数据
if (!error && response.statusCode == 200)
//第一步,读取出"data":[]数组数据
var dataJson=response.body.data;
var coinNames=[];
var coinPrice0=[];
var coinPrice4=[];
//第二部, for 循环读取每个json对象中的Key(jsonArray的名称)
for (let djson in dataJson) {
//dataJson.get(i);
coinNames.push(djson);
//第三步,[][]获取每个jsonArray中固定位置的数值
coinPrice0.push(dataJson[djson][0]);
coinPrice4.push(dataJson[djson][4]);
console.log(dataJson[djson][0]);
}
//ejs传参
res.render('account/market', {info:coinNames,coinPrice0:coinPrice0,coinPrice4:coinPrice4});
});

然后,完成。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,499
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,914
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,746
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,503
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,142
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,305