All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m51s
38 lines
535 B
Go
38 lines
535 B
Go
package json
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
type testStruct1 struct {
|
|
TS2 *testStruct2 `json:"ts2"`
|
|
}
|
|
|
|
type testStruct2 struct {
|
|
A string `json:"a"`
|
|
}
|
|
|
|
func (t *testStruct2) PreGoJsonMarshal() {
|
|
t.A = "Hello"
|
|
}
|
|
|
|
func TestGoextJsonMarshaller(t *testing.T) {
|
|
t1 := testStruct1{TS2: &testStruct2{}}
|
|
|
|
v, err := Marshal(t1)
|
|
if err != nil {
|
|
t.Fatal()
|
|
}
|
|
|
|
fmt.Printf("%s\n", v)
|
|
|
|
if string(v) != `{"ts2":{"a":"Hello"}}` {
|
|
t.Fatalf("PreGoJsonMarshal failed")
|
|
}
|
|
|
|
if t1.TS2.A != "Hello" {
|
|
t.Fatalf("PreGoJsonMarshal failed")
|
|
}
|
|
}
|