toml 0.4.0-rc.3

D implementation of TOML


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

D implementation of Tom's Obvious, Minimal Language version 0.4.0

Build Status Code Coverage DUB Package DUB Downloads

Usage

dub.json: "toml": "~>0.4.0-rc.2" dub.sdl: dependency "toml" version="~>0.4.0-rc.2"

import toml;

TOMLDocument doc;

doc = parseTOML("example = 1");
assert(doc["example"].integer == 1);

doc = parseTOML(`
	bool = true
	integer = 42
	floating = 1e2
	string = "string"
`)
assert(doc["bool"] == true);
assert(doc["integer"] == 42);
assert(doc["floating"] == 1e2);
assert(doc["string"] == "string");

// from a file
import std.file : read;
doc = parseTOML(cast(string)read("/path/to/file.toml"));

Conversion

JSON

dub.json: "toml:json": "~>0.4.0-rc.2" dub.sdl: dependency "toml:json" version="~>0.4.0-rc.2"

import std.json;

import toml;
import toml.json;

auto json = JSONValue([1, 2, 3]);
assert(toTOML(json).type == TOML_TYPE.ARRAY);
assert(toTOML(json) == [1, 2, 3]);

auto toml = parseTOML(`key = "value"`);
assert(toJSON(toml).type == JSON_TYPE.OBJECT);
assert(toJSON(toml) == JSONValue(["key": "value"]));

Missing features

  • Nested array of tables
Authors:
Kripth
Sub packages:
toml:json
Dependencies:
none
Versions:
0.4.0-rc.3 2017-Jun-09
0.4.0-rc.2 2017-Jun-08
0.4.0-rc.1 2017-Jun-08
~master 2017-Jun-09
Show all 4 versions
Download Stats:
  • 0 downloads today

  • 3 downloads this week

  • 32 downloads this month

  • 508 downloads total