我有两套服务器端的Javascripts。
1)
const marketValue = []
**************MarkLogic retrieves property value***************
marketValue.push(mktValue);
}
const isFloored = {'marketValue': fn.sum(marketValue)}
let devilBargain = {rDate, isFloored};
devilsBargain;
1) Result:
{
"rDate": "2019-01-18",
"isFloored": {
"marketValue": -36105.95
}
}
2)
const marketValue = []
**************MarkLogic retrieves property value***************
marketValue.push(mktValue);
}
const isFloored = `${fn.sum(marketValue)}`;
let devilBargain = {rDate, isFloored};
devilsBargain;
2) Result:
{
"rDate": "2019-01-18",
"isFloored": "-36105.950000000004"
}
1) 得到正确的小数点-36105.95,但不是理想的格式。
2) 得到错误的小数点"-36105.950000000004",但得到了所需的非嵌套对象格式
如何以非嵌套的JSON对象格式获得正确的小数值?
{
"rDate": "2019-01-18",
"isFloored": -36105.95
}
而不是创建 isFloored
变量的对象,并具有 marketValue
属性,为什么不创建一个只属于 sum()
的值的数组?
'use strict';
const marketValue = []
marketValue.push(-36105.95);
const rDate = "2019-01-18"
const isFloored = fn.sum(marketValue)
let devilsBargain = {rDate, isFloored};
devilsBargain;
这就产生了。
{
"rDate": "2019-01-18",
"isFloored": -36105.95
}