The OpenD Programming Language

objectsAsTable

@safe pure nothrow @nogc
objectsAsTable
(
bool allowMissingFields = true
T
)
(
return scope const(StringMap!T)[] objects
,
return scope const(string)[] header
)
if ()

Examples

import mir.algebraic_alias.csv: T = CsvAlgebraic;
import mir.algebraic: Nullable;
import mir.date: Date;
import mir.test: should;

auto o1 = ["a" : 1.T,
           "b" : 2.0.T]
    .StringMap!T;
auto o2 = ["b" : true.T,
           "c" : false.T]
    .StringMap!T;
auto o3 = ["c" : Date(2021, 12, 12).T,
           "d" : 3.T]
    .StringMap!T;

import mir.ser.text: serializeText;
[o1, o2, o3].objectsAsTable(["b", "c"]).serializeText.should
== `[["b","c"],[2.0,null],[true,false],[null,2021-12-12]]`;

[o1, o2].objectsAsTable!false(["b"]).serializeText.should
     == `[["b"],[2.0],[true]]`;

import std.exception: assertThrown;
import mir.ion.exception: IonException;
[o1, o2, o3].objectsAsTable!false(["b", "c"]).serializeText
    .assertThrown!IonException;

Meta