On Fri, 20 Sep 2013 20:07:19 GMT, Craig Dillabaugh wrote:

My Json records for a shape look like follows:

{"class":1,"type":"circle","coords":{"x":3921,"y":2607,"r":4},"id":2}

Originally the Circle struct coords were of type double, but this causes a runtime exception of the form:

object.Exception@../../.dub/packages/vibe-d-0.7.17/source/vibe/data/bson.d(597): BSON value is type 'Int', expected to be one of [Double]

Of course for "x":3921 the value of x is interpreted as an integer and the Bson.Type is set to Int. In this case this isn't a big problem, since having integer coordinates is fine for my needs. But what if, for whatever reason, I could not assume x,y and r were ints, but they could be any value (including an int). Is there any way to tell deserializeBson to interpret all numeric values as doubles (if there is no easy answer no worries, I am just curious)?

One thing that I think would help a lot in many cases would be a less strict deserialiation mode where fields can be missnig or where some conversions such as long->double are allowed. It would be trivial enough to add, but I never did something like that because I was hoping for std.serialiazion to step into that void. But AFAICS it seems like another round of review/voting is necessary before it can be included. So when there is some time in the coming days, I'll add it.