Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow serializing/deserializing BsonObject to/from a D struct #7

Open
timotheecour opened this issue Dec 2, 2016 · 0 comments
Open

Comments

@timotheecour
Copy link

timotheecour commented Dec 2, 2016

(as in json via orange library, etc)

adapting from the example in https://github.com/2night/mondo/blob/master/source/bsond.d :

BsonObject obj = 
   BO
   (
      "type", "place", 
      "address", 
      BO
      (
         "street", "main st.", 
         "number", 15
      ), 
      "tags", BA("first", "middle", "last"),
      "array", [10, 20, 30] 
   );
struct Bar{
  string street;
  int number;
}

struct Foo{
  string type;
  Bar address;
  string[]tags;
  int[]array;
}

Foo foo;
deserialize(foo, obj);
assert(foo.type=="place");
assert(serialize(foo)==obj);

it shall throw on mixed type arrays for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant