github.com/segmentio/go-tableize
go get github.com/segmentio/go-tableize

github.com/segmentio/go-tableize

Convert a nested map to a flat map of sql-friendly columns

by segmentio

v1.0.0 (see all)
go get github.com/segmentio/go-tableize
Readme

tablelize

Go tableize the given map by recursively walking the map and normalizing its keys to produce a flat SQL-friendly map.

CLI

$ go get github.com/segmentio/go-tableize/cmd/tableize
$ echo '{"user": { "id": 1 }}' | tableize
{ "user_id": 1 }

Example

event := map[string]interface{}{
  "name": map[string]interface{}{
    "first   name  ": "tobi",
    "last-name":      "holowaychuk",
  },
  "species": "ferret",
}

flat := Tableize(event)
assert(t, flat["name_first_name"] == "tobi")
assert(t, flat["name_last_name"] == "holowaychuk")
assert(t, flat["species"] == "ferret")

GitHub Stars

12

LAST COMMIT

1yr ago

MAINTAINERS

0

CONTRIBUTORS

10

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
v1.0.1-0.20210621150708-ac924d5a164c
1yr ago
v1.0.1-0.20210621124629-2255500bfcfb
1yr ago
v1.0.1-0.20190128170149-fc24ad53f554
1yr ago
v1.0.1-0.20180313202008-a782d42784c8
2yrs ago
No alternatives found
No tutorials found
Add a tutorial