dutils-data 2.0.0

Convert structs to/from and JSON/BSON with validation


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

data

DUB Package Posix Build Status

Conversion between structs and BSON/JSON with validation.

The repo contains a minified and changed version of the vibe.d JSON/BSON data module.

example

import std.stdio : writeln;

import dutils.validation.constraints : ValidateRequired, ValidateEmail;
import dutils.data.json : JSON, populateFromJSON, serializeToJSON;

struct Email {
  @ValidateRequired()
  @ValidateEmail()
  string to;

  @ValidateEmail()
  string from;

  string subject;

  @ValidateRequired()
  string body;
}

void main() {
  auto data = JSON([
      "does not exists": JSON(true),
      "to": JSON("[email protected]"),
      "body": JSON("Some text")
      ]);

  Email email;
  populateFromJSON(email, data);

  writeln("email: ", email);

  auto json = serializeToJSON(email);

  writeln("json: ", json);
}
Authors:
  • Fredrik Söderström
Dependencies:
dutils-validation, stdx-allocator
Versions:
2.0.1 2020-May-14
2.0.0 2020-May-12
1.1.1 2020-May-12
1.1.0 2020-May-12
~master 2020-May-16
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 95 downloads total

Score:
0.6
Short URL:
dutils-data.dub.pm