go-resty-expr is a toolkit for creating golang struct by expressions from lua-resty-expr
It includes an expression syntax to avoid use nest interface{} create json like array.
package main
import (
"encoding/json"
"fmt"
"github.com/incubator4/go-resty-expr/expr"
)
func main() {
var exprs = expr.And(
expr.StringExpr("arg_name").Equals(expr.StringExpr("json")),
expr.Or(
expr.StringExpr("arg_weight").GreaterThan(expr.NumberExpr(10)),
expr.StringExpr("arg_height").Not().GreaterThan(expr.NumberExpr(15)),
),
).ToArray()
bytedata, err := json.Marshal(exprs)
if err != nil {
panic(err)
}
fmt.Println(string(bytedata))
// ["AND",["arg_name","==","json"],["OR",["arg_weight","\u003e",10],["arg_height","!","\u003e",15]]]
}