import std.datetime : SysTime, Date; import toml.datetime : DateTime, TimeOfDay; assert(toJSON(TOMLValue("string")).str == "string"); assert(toJSON(TOMLValue(42)) == JSONValue(42)); assert(toJSON(TOMLValue(.1)) == JSONValue(.1)); assert(toJSON(TOMLValue(SysTime.fromISOExtString("1979-05-27T07:32:00Z"))).str == "1979-05-27T07:32:00Z"); assert(toJSON(TOMLValue(DateTime.fromISOExtString("1979-05-27T07:32:00"))).str == "1979-05-27T07:32:00"); assert(toJSON(TOMLValue(Date.fromISOExtString("1979-05-27"))).str == "1979-05-27"); assert(toJSON(TOMLValue(TimeOfDay.fromISOExtString("07:32:00"))).str == "07:32:00"); assert(toJSON(TOMLValue([1, 2, 3])) == JSONValue([1, 2, 3])); assert(toJSON(TOMLDocument(["a": TOMLValue(0), "b": TOMLValue(1)])) == JSONValue(["a": 0, "b": 1])); assert(toJSON(TOMLValue(true)).type == JSON_TYPE.TRUE); assert(toJSON(TOMLValue(false)).type == JSON_TYPE.FALSE);
Converts a TOMLValue to a JSONValue. Note: datetimes are converted to strings.