func UnmarshalBindings(body []byte) (expression.Bindings, error) { var _unmarshalled []struct { Var string `json:"variable"` Expr string `json:"expr"` Desc bool `json:"descend"` } err := json.Unmarshal(body, &_unmarshalled) if err != nil { return nil, err } bindings := make(expression.Bindings, len(_unmarshalled)) for i, binding := range _unmarshalled { expr, err := parser.Parse(binding.Expr) if err != nil { return nil, err } if binding.Desc { bindings[i] = expression.NewDescendantBinding(binding.Var, expr) } else { bindings[i] = expression.NewBinding(binding.Var, expr) } } return bindings, nil }
func (this *Let) UnmarshalJSON(body []byte) error { var _unmarshalled struct { _ string `json:"#operator"` Bindings []struct { _ string `json:"type"` Var string `json:"variable"` Expr string `json:"variable"` Desc bool `json:"descend"` } `json:"bindings"` } err := json.Unmarshal(body, &_unmarshalled) if err != nil { return err } this.bindings = make(expression.Bindings, len(_unmarshalled.Bindings)) for i, binding := range _unmarshalled.Bindings { expr, err := parser.Parse(binding.Expr) if err != nil { return err } if binding.Desc { this.bindings[i] = expression.NewDescendantBinding(binding.Var, expr) } else { this.bindings[i] = expression.NewBinding(binding.Var, expr) } } return nil }
func UnmarshalBinding(body []byte) (*expression.Binding, error) { var _unmarshalled struct { Var string `json:"variable"` Expr string `json:"expr"` Desc bool `json:"descend"` } err := json.Unmarshal(body, &_unmarshalled) if err != nil { return nil, err } expr, err := parser.Parse(_unmarshalled.Expr) if err != nil { return nil, err } if _unmarshalled.Desc { return expression.NewDescendantBinding(_unmarshalled.Var, expr), nil } else { return expression.NewBinding(_unmarshalled.Var, expr), nil } }