Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 months 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 (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-05T09:47:42.000Z (over 4 years ago)
- Last Synced: 2024-10-06T01:18:12.322Z (3 months 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: 3
- 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
[![Build Status](https://travis-ci.org/chai2010/jsonmap.svg)](https://travis-ci.org/chai2010/jsonmap)
[![Go Report Card](https://goreportcard.com/badge/github.com/chai2010/jsonmap)](https://goreportcard.com/report/github.com/chai2010/jsonmap)
[![GoDoc](https://godoc.org/github.com/chai2010/jsonmap?status.svg)](https://godoc.org/github.com/chai2010/jsonmap)## Install
1. `go get github.com/chai2010/jsonmap`
2. `go run hello.go`## Example
```go
package mainimport (
"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!