Merge pull request #2292 from markisaa/constToString

Issue 13015 - std.json.JSONValue's toString is now const
This commit is contained in:
Dmitry Olshansky 2014-07-05 12:57:22 +04:00
commit d97dc15d82

View file

@ -390,14 +390,14 @@ struct JSONValue
}
/// Implicitly calls $(D toJSON) on this JSONValue.
string toString()
string toString() const
{
return toJSON(&this);
}
/// Implicitly calls $(D toJSON) on this JSONValue, like $(D toString), but
/// also passes $(I true) as $(I pretty) argument.
string toPrettyString()
string toPrettyString() const
{
return toJSON(&this, true);
}
@ -1066,6 +1066,13 @@ unittest
}`);
}
unittest {
auto json = `"hello\nworld"`;
const jv = parseJSON(json);
assert(jv.toString == json);
assert(jv.toPrettyString == json);
}
deprecated unittest
{
// Bugzilla 12332