mirror of
https://github.com/fxkt-tech/liv
synced 2025-09-26 20:11:20 +08:00
25 lines
411 B
Go
25 lines
411 B
Go
package json_test
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/fxkt-tech/liv/pkg/encoding/json"
|
|
)
|
|
|
|
func TestPretty(t *testing.T) {
|
|
x := []byte(`{"x":1}`)
|
|
fmt.Println(json.Pretty(x))
|
|
}
|
|
|
|
type Person struct {
|
|
Name string `json:"name,omitempty"`
|
|
Age int `json:"age,omitempty"`
|
|
}
|
|
|
|
func TestToObjectT(t *testing.T) {
|
|
b := []byte(`{"name":"xx","age":1}`)
|
|
x := json.ToV[*Person](b)
|
|
fmt.Println(x.Name, x.Age)
|
|
}
|