mirror of
https://gitee.com/BDWare/agent-backend
synced 2025-01-10 09:54:11 +00:00
18 lines
442 B
Plaintext
18 lines
442 B
Plaintext
|
contract JSONExample{
|
|||
|
@Description("计算JSON数组之和,参数示例:[{\"score\":20},{\"score\":20}]")
|
|||
|
export function calculate(arg){
|
|||
|
point = JSON.parse(arg);
|
|||
|
var s = 0;
|
|||
|
print(point[0].score);
|
|||
|
print(point.length);
|
|||
|
for (var i=0;i<point.length;i++){
|
|||
|
s+=point[i].score/1.0;
|
|||
|
}
|
|||
|
var result = {
|
|||
|
};
|
|||
|
result.totalScore = s;
|
|||
|
result.count = pointer.length;
|
|||
|
return JSON.stringify(result);
|
|||
|
}
|
|||
|
}
|