Skip to content

Commit

Permalink
misc: change tapao marshal to json
Browse files Browse the repository at this point in the history
  • Loading branch information
atjhoendz committed May 10, 2024
1 parent 313a3b1 commit a2c47c9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions event_message.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ferstream

import (
"encoding/json"
"time"

"github.com/kumparan/go-utils"
Expand Down Expand Up @@ -126,13 +127,13 @@ func (n *NatsEventMessage) Build() (data []byte, err error) {
return nil, n.Error
}

message, err := tapao.Marshal(n, tapao.With(tapao.JSON))
msgInBytes, err := json.Marshal(n)
if err != nil {
n.wrapError(err)
return nil, n.Error
}

return message, nil
return msgInBytes, nil
}

// WithEvent :nodoc:
Expand Down Expand Up @@ -210,13 +211,13 @@ func (n *NatsEventMessage) AddSubject(subj string) {

// ToJSONString marshal message to JSON string
func (n *NatsEventMessage) ToJSONString() (string, error) {
bt, err := tapao.Marshal(n, tapao.With(tapao.JSON))
bt, err := json.Marshal(n)
return string(bt), err
}

// ToJSONByte marshal message to JSON byte
func (n *NatsEventMessage) ToJSONByte() ([]byte, error) {
return tapao.Marshal(n, tapao.With(tapao.JSON))
return json.Marshal(n)
}

// Build :nodoc:
Expand All @@ -225,13 +226,13 @@ func (n *NatsEventAuditLogMessage) Build() (data []byte, err error) {
return nil, n.Error
}

message, err := tapao.Marshal(n, tapao.With(tapao.JSON))
msgInBytes, err := json.Marshal(n)
if err != nil {
n.wrapError(err)
return nil, n.Error
}

return message, nil
return msgInBytes, nil
}

// ParseFromBytes :nodoc:
Expand All @@ -251,13 +252,13 @@ func (n *NatsEventAuditLogMessage) AddSubject(subj string) {

// ToJSONString marshal message to JSON string
func (n *NatsEventAuditLogMessage) ToJSONString() (string, error) {
bt, err := tapao.Marshal(n, tapao.With(tapao.JSON))
bt, err := json.Marshal(n)
return string(bt), err
}

// ToJSONByte marshal message to JSON byte
func (n *NatsEventAuditLogMessage) ToJSONByte() ([]byte, error) {
return tapao.Marshal(n, tapao.With(tapao.JSON))
return json.Marshal(n)
}

func (n *NatsEventAuditLogMessage) wrapError(err error) {
Expand Down

0 comments on commit a2c47c9

Please sign in to comment.