Skip to content

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

License

Notifications You must be signed in to change notification settings

cornelk/orderedmap

Repository files navigation

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