Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsonTree #22

Open
ddkwork opened this issue Aug 24, 2024 · 3 comments
Open

jsonTree #22

ddkwork opened this issue Aug 24, 2024 · 3 comments

Comments

@ddkwork
Copy link
Owner

ddkwork commented Aug 24, 2024

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

@ddkwork
Copy link
Owner Author

ddkwork commented Aug 24, 2024

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
Copy link
Owner Author

ddkwork commented Aug 25, 2024

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

@ddkwork
Copy link
Owner Author

ddkwork commented Aug 25, 2024

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

@ddkwork ddkwork changed the title json jsonTree Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant