mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-26 13:40:38 +03:00
Fix JSON array-based data file handling regression
This bug was introduced in Hugo 0.35. Fixes #4361
This commit is contained in:
parent
4743de0d3c
commit
4402c07775
2 changed files with 19 additions and 3 deletions
|
@ -207,6 +207,22 @@ func HandleYAMLMetaData(datum []byte) (map[string]interface{}, error) {
|
|||
// HandleJSONMetaData unmarshals JSON-encoded datum and returns a Go interface
|
||||
// representing the encoded data structure.
|
||||
func HandleJSONMetaData(datum []byte) (map[string]interface{}, error) {
|
||||
m := make(map[string]interface{})
|
||||
|
||||
if datum == nil {
|
||||
// Package json returns on error on nil input.
|
||||
// Return an empty map to be consistent with our other supported
|
||||
// formats.
|
||||
return m, nil
|
||||
}
|
||||
|
||||
err := json.Unmarshal(datum, &m)
|
||||
return m, err
|
||||
}
|
||||
|
||||
// HandleJSONData unmarshals JSON-encoded datum and returns a Go interface
|
||||
// representing the encoded data structure.
|
||||
func HandleJSONData(datum []byte) (interface{}, error) {
|
||||
if datum == nil {
|
||||
// Package json returns on error on nil input.
|
||||
// Return an empty map to be consistent with our other supported
|
||||
|
@ -214,7 +230,7 @@ func HandleJSONMetaData(datum []byte) (map[string]interface{}, error) {
|
|||
return make(map[string]interface{}), nil
|
||||
}
|
||||
|
||||
var f map[string]interface{}
|
||||
var f interface{}
|
||||
err := json.Unmarshal(datum, &f)
|
||||
return f, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue