github.com/volts-dev/volts@v0.0.0-20240120094013-5e9c65924106/codec/json_test.go (about) 1 package codec 2 3 import ( 4 "log" 5 "testing" 6 "time" 7 //"github.com/araddon/dateparse" 8 ) 9 10 func TestJosnInt64Value(t *testing.T) { 11 type Test1 struct { 12 Id int64 13 Name string 14 Time string 15 } 16 type Test2 struct { 17 Id int64 18 Name string 19 Time time.Time 20 } 21 coder := new(jsonCodec) 22 buf, err := coder.Encode(Test1{Id: 1234541341234123412, Name: "adc", Time: "2014-04-26"}) //"2016-01-02" 23 if err != nil { 24 25 } 26 27 //buf = []byte(`{"id":1234541341234123412,"Time": "2014-04-11"}`) 28 var test Test2 29 err = coder.Decode(buf, &test) 30 if err != nil { 31 t.Fatal(err) 32 } 33 log.Print(test) 34 }