RejectedSoftware Forums

Sign up

BSON deserialize Variant hashmap fails

Hi,

I need some help with this. It seems like serialization to/from BSON is not properly initializing the variant..

@("serialization") unittest {
  import unit_threaded;
  
  Variant[string] d0;
  d0["t1"] = Variant("hallo");
  trace(d0);

  Bson coded = d0.serializeToBson();

  Variant[string] d1;
  d1 = coded.deserializeBson!(Variant[string]);
  trace(d1);
  d1["t1"].get!string.shouldEqual("hello");
}

this code produces (from the trace statements)

source/msg.d:98 - ["t1":hallo]
source/msg.d:104 - ["t1":<Uninitialized VariantN>]
msg.serialization:

    std.variant.VariantException@std/variant.d(1457): Attempt to use an uninitialized VariantN

I am blocked on this now. Please help

Re: BSON deserialize Variant hashmap fails

On Tue, 23 Aug 2016 03:31:20 GMT, Øivind Loe wrote:

Hi,

I need some help with this. It seems like serialization to/from BSON is not properly initializing the variant..

@("serialization") unittest {
  import unit_threaded;
  
  Variant[string] d0;
  d0["t1"] = Variant("hallo");
  trace(d0);

  Bson coded = d0.serializeToBson();

  Variant[string] d1;
  d1 = coded.deserializeBson!(Variant[string]);
  trace(d1);
  d1["t1"].get!string.shouldEqual("hello");
}

this code produces (from the trace statements)

source/msg.d:98 - ["t1":hallo]
source/msg.d:104 - ["t1":<Uninitialized VariantN>]
msg.serialization:

    std.variant.VariantException@std/variant.d(1457): Attempt to use an uninitialized VariantN

I am blocked on this now. Please help

The preview of this message looked ok, but the post eventually looks weird. Reply to msg to see the source.

Re: BSON deserialize Variant hashmap fails

On Tue, 23 Aug 2016 03:33:39 GMT, Øivind Loe wrote:

On Tue, 23 Aug 2016 03:31:20 GMT, Øivind Loe wrote:

Hi,

I need some help with this. It seems like serialization to/from BSON is not properly initializing the variant..

The same happens with a single Variant. Seems like the BSON serialization does not support variants..