/orderedmap

A Golang Map that keeps track of the insert order of items.

Primary LanguageGoApache License 2.0Apache-2.0

orderedmap

Build status go.dev reference Go Report Card codecov

Overview

A Golang Map that keeps track of the insert order of items.

The current version can be used as a replacement for map[string]interface{} and allows JSON unmarshalling into it. No manual adding of items is currently possible.

Usage

Unmarshall and marshall JSON:

var m Map
input := `{"423":"abc","231":"dbh","152":"xyz"}`

m.UnmarshalJSON([]byte(input))

output, _ := m.MarshalJSON()
# unlike the standard Golang map, the output will be exact the same and not in random key order