mirror of
https://gitee.com/johng/gf
synced 2026-06-06 02:25:47 +08:00
fix: v2.9.5 (#4503)
This commit is contained in:
@ -76,13 +76,23 @@ func NewWithOptions(data any, options Options) *Json {
|
||||
pointedData = gconv.Interfaces(data)
|
||||
|
||||
case reflect.Map:
|
||||
pointedData = gconv.MapDeep(data, options.Tags)
|
||||
pointedData = gconv.Map(data, gconv.MapOption{
|
||||
Deep: true,
|
||||
OmitEmpty: false,
|
||||
Tags: []string{options.Tags},
|
||||
ContinueOnError: true,
|
||||
})
|
||||
|
||||
case reflect.Struct:
|
||||
if v, ok := data.(iVal); ok {
|
||||
return NewWithOptions(v.Val(), options)
|
||||
}
|
||||
pointedData = gconv.MapDeep(data, options.Tags)
|
||||
pointedData = gconv.Map(data, gconv.MapOption{
|
||||
Deep: true,
|
||||
OmitEmpty: false,
|
||||
Tags: []string{options.Tags},
|
||||
ContinueOnError: true,
|
||||
})
|
||||
|
||||
default:
|
||||
pointedData = data
|
||||
|
||||
@ -9,6 +9,7 @@ package gjson
|
||||
import "github.com/gogf/gf/v2/os/gfile"
|
||||
|
||||
// Load loads content from specified file `path`, and creates a Json object from its content.
|
||||
//
|
||||
// Deprecated: use LoadPath instead.
|
||||
func Load(path string, safe ...bool) (*Json, error) {
|
||||
var isSafe bool
|
||||
|
||||
@ -57,7 +57,12 @@ func Decode(content []byte) (map[string]any, error) {
|
||||
err = gerror.Wrap(err, `yaml.Unmarshal failed`)
|
||||
return nil, err
|
||||
}
|
||||
return gconv.MapDeep(result), nil
|
||||
return gconv.Map(result,
|
||||
gconv.MapOption{
|
||||
Deep: true,
|
||||
OmitEmpty: false,
|
||||
ContinueOnError: true,
|
||||
}), nil
|
||||
}
|
||||
|
||||
// DecodeTo parses `content` into `result`.
|
||||
|
||||
Reference in New Issue
Block a user