Fix null transmission
This commit is contained in:
@@ -33,6 +33,18 @@ func TestNewAmqp(t *testing.T) {
|
|||||||
|
|
||||||
client.Consume(event)
|
client.Consume(event)
|
||||||
|
|
||||||
|
event = &yabl.Event{
|
||||||
|
Tag: &tag,
|
||||||
|
Field: &field,
|
||||||
|
ActionName: &action,
|
||||||
|
Object: nil,
|
||||||
|
//unit: 3,
|
||||||
|
Updated: &now,
|
||||||
|
Value: nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
client.Consume(event)
|
||||||
|
|
||||||
client.Stop()
|
client.Stop()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -217,19 +217,24 @@ func (c ConnectedOut8bitType) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *Event) MarshalJSON() ([]byte, error) {
|
func (u *Event) MarshalJSON() ([]byte, error) {
|
||||||
|
var val *string
|
||||||
|
if u.Value != nil {
|
||||||
|
s := fmt.Sprintf("%v", u.Value)
|
||||||
|
val = &s
|
||||||
|
}
|
||||||
return json.Marshal(struct {
|
return json.Marshal(struct {
|
||||||
Host *string
|
Host *string
|
||||||
Unit uint
|
Unit uint
|
||||||
ActionName *AName
|
ActionName *AName
|
||||||
Field *FName
|
Field *FName
|
||||||
Updated *time.Time
|
Updated *time.Time
|
||||||
Value string
|
Value *string `json:"Value,omitempty"`
|
||||||
}{
|
}{
|
||||||
Host: u.Tag,
|
Host: u.Tag,
|
||||||
Unit: u.GetUnitId(),
|
Unit: u.GetUnitId(),
|
||||||
ActionName: u.ActionName,
|
ActionName: u.ActionName,
|
||||||
Field: u.Field,
|
Field: u.Field,
|
||||||
Updated: u.Updated,
|
Updated: u.Updated,
|
||||||
Value: fmt.Sprintf("%v", u.Value),
|
Value: val,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user