marshal_fail_case.go 413 B

1234567891011121314151617181920212223
  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "reflect"
  6. jsoniter "github.com/json-iterator/go"
  7. )
  8. type typeForTest struct {
  9. F *float64
  10. }
  11. func main() {
  12. var obj typeForTest
  13. jb1, _ := json.Marshal(obj)
  14. jb2, _ := jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(obj)
  15. if !reflect.DeepEqual(jb1, jb2) {
  16. fmt.Printf("results differ:\n expected: `%s`\n got: `%s`\n", string(jb1), string(jb2))
  17. }
  18. }