mirror of
https://github.com/json-iterator/go.git
synced 2025-03-23 21:09:11 +02:00
decode []byte using ReadBase64
This commit is contained in:
parent
b04c1e7485
commit
7e295ba1a5
@ -4,6 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_reflect_str(t *testing.T) {
|
func Test_reflect_str(t *testing.T) {
|
||||||
@ -274,6 +275,18 @@ func Test_reflect_nested(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_reflect_base64(t *testing.T) {
|
||||||
|
iter := ParseString(`"YWJj"`)
|
||||||
|
val := []byte{}
|
||||||
|
RegisterTypeDecoder("[]uint8", func(ptr unsafe.Pointer, iter *Iterator) {
|
||||||
|
*((*[]byte)(ptr)) = iter.ReadBase64()
|
||||||
|
})
|
||||||
|
defer ClearDecoders()
|
||||||
|
iter.Read(&val)
|
||||||
|
if "abc" != string(val) {
|
||||||
|
t.Fatal(string(val))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type StructOfTagOne struct {
|
type StructOfTagOne struct {
|
||||||
field1 string `json:"field1"`
|
field1 string `json:"field1"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user