我有一个JSON对象中包含的数组,我将其传递到快速JS模板中,似乎它在某个地方丢失了括号。
当我在console.log(JSON.stringify(theJSONObject))时,我看到的是:
[["2016-12-01","20.65"],["2016-12-02","20.46"],["2016-12-05","21.85"],["2016-12-06","20.57"],["2016-12-07","22.10"],["2016-12-08","21.55"],["2016-12-09","21.72"],["2016-12-12","21.54"],["2016-12-13","22.30"],["2016-12-14","21.79"],["2016-12-15","21.29"],["2016-12-16","20.92"],["2016-12-19","20.85"],["2016-12-20","21.79"],["2016-12-21","22.30"],["2016-12-22","22.14"],["2016-12-23","21.91"],["2016-12-27","21.29"],["2016-12-28","21.02"],["2016-12-29","21.06"],["2016-12-30","20.83"]]
但是,当我将JSONObject提供给EJS模板时,所有括号都消失了,我在HTML中看到的只是
"2016-12-01","20.65","2016-12-02","20.46","2016-12-05","21.85","2016-12-06","20.57","2016-12-07","22.10","2016-12-08","21.55","2016-12-09","21.72","2016-12-12","21.54","2016-12-13","22.30","2016-12-14","21.79","2016-12-15","21.29","2016-12-16","20.92","2016-12-19","20.85","2016-12-20","21.79","2016-12-21","22.30","2016-12-22","22.14","2016-12-23","21.91","2016-12-27","21.29","2016-12-28","21.02","2016-12-29","21.06","2016-12-30","20.83"
可能是什么问题?
答案 0 :(得分:0)
JS一定很困惑,因为这些数字是以字符串形式读取的。当我将它们改为数字时(即25而不是" 25")然后在数组中读取工作正常。