Documentation
¶
Overview ¶
Interconversion between map list and slice
Index ¶
- func MaplistToTable[K cmp.Ordered, V comparable](maplist []map[K]V, fixedColumns []K) (tblheader []K, tbldata [][]V)
- func ReadJson[K comparable, V any](r io.Reader) ([]map[K]V, error)
- func TableToMaplist[K cmp.Ordered, V comparable](tblheader []K, tbldata [][]V, ignoreZero bool) (maplist []map[K]V)
- func WriteJson[K comparable, V any](w io.Writer, maplist []map[K]V) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaplistToTable ¶ added in v0.2.0
func MaplistToTable[K cmp.Ordered, V comparable](maplist []map[K]V, fixedColumns []K) (tblheader []K, tbldata [][]V)
MaplistToTable : Convert map list to table.
e.g.: [{"key1": 1, "key2": 2}, {"key1": 3, "key2": 4}] => ["key1", "key2"] and [[1, 2], [3, 4]]
Empty elements has a zero value of type V.
Order of the columns is such that the `fixedColumns` are placed first if they exist, followed by the other keys sorted in ascending order. `fixColumns` accepts nil.
func ReadJson ¶ added in v0.2.0
func ReadJson[K comparable, V any](r io.Reader) ([]map[K]V, error)
ReadJson : Read JSON format data to map list.
func TableToMaplist ¶ added in v0.2.0
func TableToMaplist[K cmp.Ordered, V comparable](tblheader []K, tbldata [][]V, ignoreZero bool) (maplist []map[K]V)
TableToMaplist : Convert table to map list.
e.g.: ["key1", "key2"] and [[1, 2], [3, 4]] => [{"key1": 1, "key2": 2}, {"key1": 3, "key2": 4}]
If the size of the data row is larger than the size of the header, discard the value. If `ignoreZero` is true, do not store zero values.
Types ¶
This section is empty.