Open ddkwork opened 3 months ago
package main
import (
"encoding/json"
"fmt"
"github.com/bournex/ordered_container"
)
func main() {
jsonstr := []byte(`{"name":"alice","age":5}`)
var orderedMap ordered_container.OrderedMap
json.Unmarshal(jsonstr, &orderedMap)
b, _ := json.Marshal(orderedMap)
fmt.Println(string(b)) // 输出`{"name":"alice","age":5}`
unorderdMap := map[string]interface{}{}
json.Unmarshal(jsonstr, &unorderdMap)
b2, _ := json.Marshal(unorderdMap)
fmt.Println(string(b2)) // 输出`{"age":5,"name":"alice"}`
}
提取n叉树,并增加检测key去重功能,即map特性
为目前的jsontree增加code和tag字段,以及序列化json和原始json eq的测试
https://github.com/Andrew-M-C/go.jsonvalue/blob/master/jsonvalue.go#L513-L516