tabulate

Tabulate an array of associative array.

This version tabulates an array of associative array. The keys will be used as headers and there is no need to align each keys of each array elements. If some missing key exists in the one line, that cell will be empty.

Parameters

data Value[Key][]

An array of associative array data

config Config

A configuration to set appearance

Return Value

Type: string

The table string

Examples

const testdata = [
    [
        "マスコットキャラクタ": "D-man",
        "about": "Programming Language"
    ],
    [
        "マスコットキャラクタ": "D言語くん",
        "about": "プログラミング言語"
    ],
];
const reference =
    " マスコットキャラクタ          about         \n" ~
    "---------------------- ----------------------\n" ~
    "        D-man           Programming Language \n" ~
    "      D言語くん          プログラミング言語  ";
assert(tabulate(testdata, Config(Style.simple, Align.center, true)) == reference);

Meta