Esempio n. 1
0
/*
Unmarshals byte array.
*/
func UnmarshalUpdateFor(body []byte) (*algebra.UpdateFor, error) {
	var _unmarshalled struct {
		Bindings json.RawMessage `json:"bindings"`
		When     string          `json:"when"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return nil, err
	}

	bindings, err := unmarshal.UnmarshalBindings(_unmarshalled.Bindings)
	if err != nil {
		return nil, err
	}

	var when expression.Expression
	if _unmarshalled.When != "" {
		when, err = parser.Parse(_unmarshalled.When)
		if err != nil {
			return nil, err
		}
	}

	return algebra.NewUpdateFor(bindings, when), nil
}
Esempio n. 2
0
func (this *Let) UnmarshalJSON(body []byte) error {
	var _unmarshalled struct {
		_        string          `json:"#operator"`
		Bindings json.RawMessage `json:"bindings"`
	}

	err := json.Unmarshal(body, &_unmarshalled)
	if err != nil {
		return err
	}

	this.bindings, err = unmarshal.UnmarshalBindings(_unmarshalled.Bindings)
	return err
}