Documentation
¶
Overview ¶
Package jsonengine 提供基于 jsonvalue 的 JSON 规则引擎
Index ¶
Constants ¶
View Source
const ( ErrNotFound = jsonvalue.ErrNotFound ErrTypeNotMatch = jsonvalue.ErrTypeNotMatch ErrImportTargetValue = jsonvalue.Error("import target value error") ErrIllegalOperator = jsonvalue.Error("illegal operator") )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Condition ¶
type Condition struct {
Expr
OR OR `json:"or,omitempty" yaml:"or,omitempty"`
AND AND `json:"and,omitempty" yaml:"and,omitempty"`
NOT *NOT `json:"not,omitempty" yaml:"not,omitempty"`
}
Condition 表示一个条件
func (*Condition) UnmarshalJSON ¶
UnmarshalJSON is redefined to support simple SQL style expression written as a 3-element-array, like ["result.list.[+].code", "=", 200]
type Expr ¶
type Expr struct {
Field string `json:"field,omitempty" yaml:"field,omitempty"`
Operator string `json:"op" yaml:"op"`
Value any `json:"value" yaml:"value"`
// contains filtered or unexported fields
}
Expr 表示一个最简单的表达式条件。
Field 使用点分隔, 需要注意的是, [*] 表示数组中所有的类型都需要匹配, [+] 表示数组中任意一个满足条件即可
type Option ¶
type Option func(*options)
Option 表示可用参数
func OptDateTimeFormat ¶
OptDateTimeFormat 表示时间格式, Go 格式, 用于当目标是 string 的时候, 检查是不是时间
func OptWhenTypeMismatch ¶
func OptWhenTypeMismatch(typ ReturnType) Option
OptWhenTypeMismatch 表示当值类型不匹配时, 如何返回
type ReturnType ¶
type ReturnType uint
ReturnType 表示如何返回
const ( // ReturnError 表示返回 jsonvalue 的错误 ReturnError ReturnType = iota // ReturnFalse 表示返回不匹配 ReturnFalse )
Click to show internal directories.
Click to hide internal directories.