func (d *Delta) UnmarshalJSON(data []byte) error {
	var elements []json.RawMessage
	if err := json.Unmarshal(data, &elements); err != nil {
		return err
	}
	if len(elements) != 3 {
		return fmt.Errorf(
			"Expected 3 elements in top-level of JSON but got %d",
			len(elements))
	}
	var entityKind, operation string
	if err := json.Unmarshal(elements[0], &entityKind); err != nil {
		return err
	}
	if err := json.Unmarshal(elements[1], &operation); err != nil {
		return err
	}
	if operation == "remove" {
		d.Removed = true
	} else if operation != "change" {
		return fmt.Errorf("Unexpected operation %q", operation)
	}
	switch entityKind {
	case "action":
		d.Entity = new(ActionInfo)
	case "annotation":
		d.Entity = new(AnnotationInfo)
	case "application":
		d.Entity = new(ApplicationInfo)
	case "applicationOffer":
		d.Entity = new(ApplicationOfferInfo)
	case "block":
		d.Entity = new(BlockInfo)
	case "branch":
		d.Entity = new(BranchInfo)
	case "charm":
		d.Entity = new(CharmInfo)
	case "machine":
		d.Entity = new(MachineInfo)
	case "model":
		d.Entity = new(ModelUpdate)
	case "relation":
		d.Entity = new(RelationInfo)
	case "remoteApplication":
		d.Entity = new(RemoteApplicationUpdate)
	case "unit":
		d.Entity = new(UnitInfo)
	default:
		return errors.Errorf("Unexpected entity name %q", entityKind)
	}
	return json.Unmarshal(elements[2], &d.Entity)
}
// UnmarshalJSON implements json.Unmarshaler.
UnmarshalJSON implements json.Unmarshaler.
// UnmarshalJSON implements json . Unmarshaler .
func (d *Delta) UnmarshalJSON(data []byte) error {
	var elements []json.RawMessage
	if err := json.Unmarshal(data, &elements); err != nil {
		return err
	}
	if len(elements) != 3 {
		return fmt.Errorf(
			"Expected 3 elements in top-level of JSON but got %d",
			len(elements))
	}
	var entityKind, operation string
	if err := json.Unmarshal(elements[0], &entityKind); err != nil {
		return err
	}
	if err := json.Unmarshal(elements[1], &operation); err != nil {
		return err
	}
	if operation == "remove" {
		d.Removed = true
	} else if operation != "change" {
		return fmt.Errorf("Unexpected operation %q", operation)
	}
	switch entityKind {
	case "action":
		d.Entity = new(ActionInfo)
	case "annotation":
		d.Entity = new(AnnotationInfo)
	case "application":
		d.Entity = new(ApplicationInfo)
	case "applicationOffer":
		d.Entity = new(ApplicationOfferInfo)
	case "block":
		d.Entity = new(BlockInfo)
	case "branch":
		d.Entity = new(BranchInfo)
	case "charm":
		d.Entity = new(CharmInfo)
	case "machine":
		d.Entity = new(MachineInfo)
	case "model":
		d.Entity = new(ModelUpdate)
	case "relation":
		d.Entity = new(RelationInfo)
	case "remoteApplication":
		d.Entity = new(RemoteApplicationUpdate)
	case "unit":
		d.Entity = new(UnitInfo)
	default:
		return errors.Errorf("Unexpected entity name %q", entityKind)
	}
	return json.Unmarshal(elements[2], &d.Entity)
}
func ( d * Delta ) UnmarshalJSON ( data [ ] byte ) error { var elements [ ] json . RawMessage if err := json . Unmarshal ( data , & elements ) ; err != nil { return err } if len ( elements ) != 3 { return fmt . Errorf ( " " , len ( elements ) ) } var entityKind , operation string if err := json . Unmarshal ( elements [ 0 ] , & entityKind ) ; err != nil { return err } if err := json . Unmarshal ( elements [ 1 ] , & operation ) ; err != nil { return err } if operation == " " { d . Removed = true } else if operation != " " { return fmt . Errorf ( " " , operation ) } switch entityKind { case " " : d . Entity = new ( ActionInfo ) case " " : d . Entity = new ( AnnotationInfo ) case " " : d . Entity = new ( ApplicationInfo ) case " " : d . Entity = new ( ApplicationOfferInfo ) case " " : d . Entity = new ( BlockInfo ) case " " : d . Entity = new ( BranchInfo ) case " " : d . Entity = new ( CharmInfo ) case " " : d . Entity = new ( MachineInfo ) case " " : d . Entity = new ( ModelUpdate ) case " " : d . Entity = new ( RelationInfo ) case " " : d . Entity = new ( RemoteApplicationUpdate ) case " " : d . Entity = new ( UnitInfo ) default : return errors . Errorf ( " " , entityKind ) } return json . Unmarshal ( elements [ 2 ] , & d . Entity ) }
UnmarshalJSON implements json.Unmarshaler.
UnmarshalJSON implements json . Unmarshaler .