mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
fix issue in package gjson for struct to map converting
This commit is contained in:
@ -74,7 +74,7 @@ func NewWithTag(data interface{}, tags string, safe ...bool) *Json {
|
||||
i := interface{}(nil)
|
||||
// Note that it uses Map function implementing the converting.
|
||||
// Note that it here should not use MapDeep function if you really know what it means.
|
||||
i = gconv.MapDeep(data, tags)
|
||||
i = gconv.Map(data, tags)
|
||||
j = &Json{
|
||||
p: &i,
|
||||
c: byte(gDEFAULT_SPLIT_CHAR),
|
||||
|
||||
@ -13,8 +13,9 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// ConfigCompatibleWithStandardLibrary tries to be 80% compatible
|
||||
// ConfigCompatibleWithStandardLibrary tries to be 50% compatible
|
||||
// with standard library behavior.
|
||||
// 50% - -!
|
||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
|
||||
// Marshal adapts to json/encoding Marshal API.
|
||||
@ -49,8 +50,8 @@ func Unmarshal(data []byte, v interface{}) error {
|
||||
}
|
||||
|
||||
// NewEncoder same as json.NewEncoder
|
||||
func NewEncoder(writer io.Writer) *jsoniter.Encoder {
|
||||
return json.NewEncoder(writer)
|
||||
func NewEncoder(writer io.Writer) *json2.Encoder {
|
||||
return json2.NewEncoder(writer)
|
||||
}
|
||||
|
||||
// NewDecoder adapts to json/stream NewDecoder API.
|
||||
@ -59,8 +60,8 @@ func NewEncoder(writer io.Writer) *jsoniter.Encoder {
|
||||
//
|
||||
// Instead of a json/encoding Decoder, an Decoder is returned
|
||||
// Refer to https://godoc.org/encoding/json#NewDecoder for more information.
|
||||
func NewDecoder(reader io.Reader) *jsoniter.Decoder {
|
||||
return json.NewDecoder(reader)
|
||||
func NewDecoder(reader io.Reader) *json2.Decoder {
|
||||
return json2.NewDecoder(reader)
|
||||
}
|
||||
|
||||
// Valid reports whether data is a valid JSON encoding.
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
import jsoniter "github.com/json-iterator/go"
|
||||
|
||||
var json = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
|
||||
func main() {
|
||||
body := "{\"id\": 413231383385427875}"
|
||||
m := make(map[string]interface{})
|
||||
json.Unmarshal([]byte(body), &m)
|
||||
b, _ := json.Marshal(m)
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
Reference in New Issue
Block a user