asdfSerializer

Create ASDF serialization back-end

asdfSerializer
(
size_t initialLength = 32
)

Examples

import asdf;
import mir.conv: to;
import std.bigint;
import std.format: singleSpec;

auto ser = asdfSerializer();
auto state0 = ser.structBegin;

    ser.putEscapedKey("null");
    ser.putValue(null);

    ser.putKey("array");
    auto state1 = ser.listBegin();
        ser.elemBegin; ser.putValue(null);
        ser.elemBegin; ser.putValue(123);
        ser.elemBegin; ser.putNumberValue(12300000.123, singleSpec("%.10e"));
        ser.elemBegin; ser.putValue("\t");
        ser.elemBegin; ser.putValue("\r");
        ser.elemBegin; ser.putValue("\n");
        ser.elemBegin; ser.putNumberValue(BigInt("1234567890"));
    ser.listEnd(state1);

ser.structEnd(state0);

assert(ser.app.result.to!string == `{"null":null,"array":[null,123,1.2300000123e+07,"\t","\r","\n",1234567890]}`);

Meta