package main
import (
"encoding/json"
"fmt"
"reflect"
)
func main() {
nodeArray := map[string]interface{}{
"meta": map[string]interface{}{
"category": "paragraph"}, "content": []string{"111"}}
// content is number as 111 or array
b, _ := json.Marshal(&nodeArray)
var nodeArrayTest map[string]interface{}
json.Unmarshal(b, &nodeArrayTest)
if !reflect.DeepEqual(nodeArray, nodeArrayTest) {
fmt.Println("!!!! odeArray and nodeArrayTest should be equal")
} else {
fmt.Println("odeArray and nodeArrayTest equal")
}
}
Why when the interface map has array(content is number as 111 or array), the return of DeepEqual is false? And when the content value is a string, a map, the DeepEqual is true.