如何编写JSON公式

huangapple go评论123阅读模式
英文:

How to write a json formula

问题

以下是翻译好的内容:

"formula": {
"operation": "*",
"left": {
"operation": "-",
"left": {
"operation": "value",
"type": "custom_fields",
"value": "last_price"
},
"right": {
"operation": "value",
"type": "custom_fields",
"value": "cost"
}
},
"right": {
"operation": "value",
"type": "const",
"field": 100
}
}

英文:

I am writing a json formula to calculate a custom value, need it to look like this:(last_price - cost) / last_price * 100. I am a little confused on where to put left and right parts of the calculation, like what should go first - "100" or "/last_price"

I wrote this, which makes it into (last_price-cost)*100 I guess:

"formula": {
   "operation": "*",
    "left": {
     "operation": "-",
     "left": {
     "operation": "value",
      "type": "custom_fields",
      "value": "last_price"
  },
  "right": {
    "operation": "value",
    "type": "custom_fields",
    "value": "cost"
  }
  },
  "right":{
    "operation": "value",
    "type": "const",
    "field": 100

答案1

得分: 0

朋友建议将公式更改为(1 - 成本 / 最后价格)* 100,这样我更容易理解。

英文:

Friend recommended to change formula to (1 - cost / last_price) * 100, which makes it much easier for me to put into.

huangapple
  • 本文由 发表于 2023年3月9日 20:36:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75684717.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定