mirror of
https://github.com/json-iterator/go.git
synced 2025-02-07 19:30:06 +02:00
24 lines
536 B
Go
24 lines
536 B
Go
|
package extra
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
"github.com/json-iterator/go"
|
||
|
"github.com/json-iterator/go/require"
|
||
|
)
|
||
|
|
||
|
func Test_lower_case_with_underscores(t *testing.T) {
|
||
|
should := require.New(t)
|
||
|
should.Equal("hello_world", LowerCaseWithUnderscores("helloWorld"))
|
||
|
should.Equal("hello_world", LowerCaseWithUnderscores("HelloWorld"))
|
||
|
SetNamingStrategy(LowerCaseWithUnderscores)
|
||
|
output, err := jsoniter.MarshalToString(struct {
|
||
|
HelloWorld string
|
||
|
}{
|
||
|
HelloWorld: "hi",
|
||
|
})
|
||
|
should.Nil(err)
|
||
|
should.Equal(`{"hello_world":"hi"}`, output)
|
||
|
}
|
||
|
|
||
|
|