作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用data_str = JSON.stringify(data); 转换为字符串。 json 中的数据是
[{"temperSensorData":"28.489084691371996","temperSensorUnit":"celsius","timestamp":"1493270171424","timestamp2":"1493270171454","timestamp3":"1493270171454","val":"0"},{"temperSensorData":"28.48908469137112","temperSensorUnit":"celsius","timestamp":"1493270171426","timestamp2":"1493270171522","timestamp3":"1493270171523","val":"1"},{"temperSensorData":"28.489084691371186","temperSensorUnit":"celsius","timestamp":"1493270171426","timestamp2":"1493270171523","timestamp3":"1493270171524","val":"2"},{"temperSensorData":"28.489084691371595","temperSensorUnit":"celsius","timestamp":"1493270171426","timestamp2":"1493270171524","timestamp3":"1493270171525","val":"3"},{"temperSensorData":"28.48908469137168","temperSensorUnit":"celsius","timestamp":"1493270171428","timestamp2":"1493270171529","timestamp3":"1493270171529","val":"4"},{"temperSensorData":"28.489084691371684","temperSensorUnit":"celsius","timestamp":"1493270171428","timestamp2":"1493270171529","timestamp3":"1493270171529","val":"5"},{"temperSensorData":"28.489084691371357","temperSensorUnit":"celsius","timestamp":"1493270171429","timestamp2":"1493270171530","timestamp3":"1493270171531","val":"6"},{"temperSensorData":"28.489084691371144","temperSensorUnit":"celsius","timestamp":"1493270171429","timestamp2":"1493270171531","timestamp3":"1493270171532","val":"7"},{"temperSensorData":"28.48908469137181","temperSensorUnit":"celsius","timestamp":"1493270171431","timestamp2":"1493270171546","timestamp3":"1493270171546","val":"25"}]
现在我想获取时间戳值并执行一些数学运算。如何将其转换为浮点值?即使我使用了 parseInt(timestamp) 和 Number(timestamp),它也不起作用并显示结果:NaN。
最佳答案
尝试 parseFloat("28.489084691371996") 函数。它会对你有所帮助。
parseFloat("28.489084691371996")
如果您需要进一步帮助,请告诉我。
关于javascript - 如何在javascript中将stringyfied数组值转换为float,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43730396/
当我尝试用对象的方法填充一些innerHTML 时,我遇到了问题。奇怪的是,引用一个函数是有效的。但第二种方式对于我想做的事情来说并不方便,这就是我寻求帮助的原因。有办法让它工作吗? 有一些代码可以解
我是一名优秀的程序员,十分优秀!