https://github.com/ake-persson/mapslice-json
Go MapSlice for ordered marshal/ unmarshal of maps in JSON
https://github.com/ake-persson/mapslice-json
go json map mapslice slice
Last synced: 11 days ago
JSON representation
Go MapSlice for ordered marshal/ unmarshal of maps in JSON
- Host: GitHub
- URL: https://github.com/ake-persson/mapslice-json
- Owner: ake-persson
- License: apache-2.0
- Created: 2020-02-19T11:01:48.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-08T08:51:37.000Z (about 1 year ago)
- Last Synced: 2024-04-14T12:12:59.217Z (about 1 year ago)
- Topics: go, json, map, mapslice, slice
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 17
- Watchers: 1
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - mapslice-json - Go MapSlice for ordered marshal/ unmarshal of maps in JSON. (JSON / Search and Analytic Databases)
- awesome-go-extra - mapslice-json - 02-19T11:01:48Z|2022-07-26T21:44:15Z| (JSON / Advanced Console UIs)
README
[](https://godoc.org/github.com/ake-persson/mapslice-json)
[](https://goreportcard.com/report/github.com/ake-persson/mapslice-json)
[](https://github.com/ake-persson/mapslice-json/blob/master/LICENSE)
[](https://coveralls.io/github/ake-persson/mapslice-json?branch=master)
[](https://travis-ci.org/ake-persson/mapslice-json)# mapslice-json
Go MapSlice for ordered marshal/ unmarshal of maps in JSON
# Example
```go
package mainimport (
"encoding/json"
"fmt"
"log""github.com/ake-persson/mapslice-json"
)func main() {
ms := mapslice.MapSlice{
mapslice.MapItem{Key: "abc", Value: 123},
mapslice.MapItem{Key: "def", Value: 456},
mapslice.MapItem{Key: "ghi", Value: 789},
}b, err := json.Marshal(ms)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))ms = mapslice.MapSlice{}
if err := json.Unmarshal(b, &ms); err != nil {
log.Fatal(err)
}fmt.Println(ms)
}
```