Skip to content

Commit

Permalink
support json null object
Browse files Browse the repository at this point in the history
  • Loading branch information
tenfyzhong committed Jan 7, 2024
1 parent 542b68b commit d55355e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions st2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ func TestConvert(t *testing.T) {
"hello": true
}
},
"gg": []
"gg": [],
"h": null
}]
`)),
}
Expand Down Expand Up @@ -174,6 +175,7 @@ type Root struct {
D []*D ` + "`json:\"d,omitempty\"`" + `
E *E ` + "`json:\"e,omitempty\"`" + `
F *F ` + "`json:\"f,omitempty\"`" + `
H any ` + "`json:\"h,omitempty\"`" + `
}
`),
Expand Down Expand Up @@ -212,7 +214,8 @@ type Root struct {
"hello": true
}
},
"gg": []
"gg": [],
"h": null
}]
`)),
}
Expand Down Expand Up @@ -249,6 +252,7 @@ message Root {
repeated D d = 4;
E e = 5;
F f = 6;
google.protobuf.Any h = 8;
}
`),
Expand Down Expand Up @@ -287,7 +291,8 @@ message Root {
"hello": true
}
},
"gg": []
"gg": [],
"h": null
}]
`)),
}
Expand Down Expand Up @@ -324,6 +329,7 @@ struct Root {
4: list<D> d,
5: E e,
6: F f,
8: binary h,
}
`),
Expand Down
6 changes: 3 additions & 3 deletions type.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ type Type interface {
type NullType struct{}

func (v NullType) Json() string { return "null" }
func (v NullType) Go() string { return "interface{}" }
func (v NullType) Proto() string { return "" }
func (v NullType) Thrift() string { return "" }
func (v NullType) Go() string { return "any" }
func (v NullType) Proto() string { return "google.protobuf.Any" }
func (v NullType) Thrift() string { return "binary" }
func (v NullType) Value() string { return "nil" }
func (v NullType) IsBasicType() bool { return false }

Expand Down

0 comments on commit d55355e

Please sign in to comment.