Representing logic as data in JSON

前端 未结 12 1492
眼角桃花
眼角桃花 2021-01-29 21:37

For business reasons we need to externalize some conditional logic into external files: preferably JSON.

A simple filter-by scenario could be handled by adding a node a

12条回答
  •  醉酒成梦
    2021-01-29 21:53

    My colleague suggested this possible solution:

    "all OR conditions would be an array while AND conditions would be objects,

    For example,OR can match any of the objects in the array:

    [
      {
        "var1":"value1"
      },
      {
        "var2":"value2"
      },
      {
        "var3":"value3"
      }
    ]
    

    AND would be

    { 
      "var1":"val1",
      "var2":"val2",
      "var3":"val3"
    }
    

提交回复
热议问题