|
|
@@ -48,3 +48,17 @@ func Test_set_naming_strategy_with_omitempty(t *testing.T) {
|
|
|
should.Nil(err)
|
|
|
should.Equal(`{"user_name":"taowen"}`, string(output))
|
|
|
}
|
|
|
+
|
|
|
+func Test_set_naming_strategy_with_private_field(t *testing.T) {
|
|
|
+ should := require.New(t)
|
|
|
+ SetNamingStrategy(LowerCaseWithUnderscores)
|
|
|
+ output, err := jsoniter.Marshal(struct {
|
|
|
+ UserName string
|
|
|
+ userId int
|
|
|
+ }{
|
|
|
+ UserName: "allen",
|
|
|
+ userId: 100,
|
|
|
+ })
|
|
|
+ should.Nil(err)
|
|
|
+ should.Equal(`{"user_name":"allen"}`, string(output))
|
|
|
+}
|