ddkwork / golibrary

Apache License 2.0
0 stars 1 forks source link

jsonTree #22

Open ddkwork opened 3 months ago

ddkwork commented 3 months ago

https://github.com/Andrew-M-C/go.jsonvalue/blob/master/jsonvalue.go#L513-L516

ddkwork commented 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"}`
}
ddkwork commented 3 months ago

提取n叉树,并增加检测key去重功能,即map特性

ddkwork commented 3 months ago

为目前的jsontree增加code和tag字段,以及序列化json和原始json eq的测试