mirror of
https://github.com/retailcrm/api-client-go.git
synced 2024-11-22 04:46:03 +03:00
parent
e68199efb3
commit
d551e91985
7
v5/marshaling.go
Normal file
7
v5/marshaling.go
Normal file
@ -0,0 +1,7 @@
|
||||
package v5
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
func (t Tag) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(t.Name)
|
||||
}
|
24
v5/marshaling_test.go
Normal file
24
v5/marshaling_test.go
Normal file
@ -0,0 +1,24 @@
|
||||
package v5
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTag_MarshalJSON(t *testing.T) {
|
||||
tags := []Tag{
|
||||
{"first", "#3e89b6", false},
|
||||
{"second", "#ffa654", false},
|
||||
}
|
||||
names := []byte(`["first","second"]`)
|
||||
str, err := json.Marshal(tags)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("%v", err.Error())
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(str, names) {
|
||||
t.Errorf("Marshaled: %#v\nExpected: %#v\n", str, names)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user