https://github.com/chai2010/jsonmap
Map for json/struct/key-value-db
https://github.com/chai2010/jsonmap
etcd json json-map jsonmap structmap
Last synced: about 1 year ago
JSON representation
Map for json/struct/key-value-db
- Host: GitHub
- URL: https://github.com/chai2010/jsonmap
- Owner: chai2010
- License: bsd-3-clause
- Created: 2018-04-10T05:41:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-07-05T09:47:42.000Z (almost 6 years ago)
- Last Synced: 2025-04-06T07:37:24.720Z (about 1 year ago)
- Topics: etcd, json, json-map, jsonmap, structmap
- Language: Go
- Homepage: https://godoc.org/github.com/chai2010/jsonmap
- Size: 15.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
- *Go语言QQ群: 102319854, 1055927514*
- *凹语言(凹读音“Wa”)(The Wa Programming Language): https://github.com/wa-lang/wa*
----
# Map for Json/Struct/Key-Value-Database
[](https://travis-ci.org/chai2010/jsonmap)
[](https://goreportcard.com/report/github.com/chai2010/jsonmap)
[](https://godoc.org/github.com/chai2010/jsonmap)
## Install
1. `go get github.com/chai2010/jsonmap`
2. `go run hello.go`
## Example
```go
package main
import (
"fmt"
"sort"
"github.com/chai2010/jsonmap"
)
func main() {
var jsonMap = jsonmap.JsonMap{
"a": map[string]interface{}{
"sub-a": "value-sub-a",
},
"b": map[string]interface{}{
"sub-b": "value-sub-b",
},
"c": 123,
"d": 3.14,
"e": true,
"x": map[string]interface{}{
"a": map[string]interface{}{
"sub-a": "value-sub-a",
},
"b": map[string]interface{}{
"sub-b": "value-sub-b",
},
"c": 123,
"d": 3.14,
"e": true,
"z": map[string]interface{}{
"zz": "value-zz",
},
},
}
m := jsonMap.ToMapString("/")
var keys []string
for k := range m {
keys = append(keys, k)
}
sort.Strings(keys)
for _, k := range keys {
fmt.Println(k, m[k])
}
// Output:
// /a/sub-a value-sub-a
// /b/sub-b value-sub-b
// /c 123
// /d 3.14
// /e true
// /x/a/sub-a value-sub-a
// /x/b/sub-b value-sub-b
// /x/c 123
// /x/d 3.14
// /x/e true
// /x/z/zz value-zz
}
```
## BUGS
Report bugs to .
Thanks!