Representing logic as data in JSON

前端 未结 12 1495
眼角桃花
眼角桃花 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:54

    By the way, IBM DB2 supports logic statements encoded in JSON.

    Boolean operations look like a cross between cHao's solution and Amazon CloudFormation:

    {"$and":[{"age":5},{"name":"Joe"}]}
    

    Comparison operations look, to me, like transliterated SQL. (Instead of Amazon or Russellg or cHao's movement toward an abstract syntax tree.)

    {"age":{"$lt":3}}
    

提交回复
热议问题