Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 2 months 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 (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-08T08:51:37.000Z (10 months ago)
- Last Synced: 2024-04-14T12:12:59.217Z (8 months 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
[![GoDoc](https://godoc.org/github.com/ake-persson/mapslice-json?status.svg)](https://godoc.org/github.com/ake-persson/mapslice-json)
[![Go Report Card](https://goreportcard.com/badge/github.com/ake-persson/mapslice-json)](https://goreportcard.com/report/github.com/ake-persson/mapslice-json)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/ake-persson/mapslice-json/blob/master/LICENSE)
[![Coverage Status](https://coveralls.io/repos/github/ake-persson/mapslice-json/badge.svg?branch=master)](https://coveralls.io/github/ake-persson/mapslice-json?branch=master)
[![Build Status](https://travis-ci.org/ake-persson/mapslice-json.svg?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)
}
```