Categorygitlab.com/c0b/go-ordered-json
modulepackage
0.0.0-20201030195603-febf46534d5a
Repository: https://gitlab.com/c0b/go-ordered-json.git
Documentation: pkg.go.dev

# README

JSON object parsing with preserving keys order

coverage

Refers

  1. JSON and Go https://blog.golang.org/json-and-go
  2. Go-Ordered-JSON https://github.com/virtuald/go-ordered-json from this thread Preserving key order in encoding/json and the Abandoned 7930: encoding/json: Optionally preserve the key order of JSON objects
  3. Python OrderedDict https://github.com/python/cpython/blob/2.7/Lib/collections.py#L38 the Python's OrderedDict uses a double linked list internally, maintain a consistent public interface with dict

Disclaimer:

same as Go's default map, this OrderedMap is not safe for concurrent use, if need atomic access, may use a sync.Mutex to synchronize.

# Functions

Create a new OrderedMap.
Create a new OrderedMap and populate from a list of key-value pairs.

# Structs

the key-value pair type, for initializing from a list of key-value pairs, or for looping entries in the same order.
the OrderedMap type, has similar operations as the default map, but maintained the keys order of inserted; similar to map, all single key operations (Get/Set/Delete) runs at O(1).