mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
Merge pull request #2292 from markisaa/constToString
Issue 13015 - std.json.JSONValue's toString is now const
This commit is contained in:
commit
d97dc15d82
1 changed files with 9 additions and 2 deletions
11
std/json.d
11
std/json.d
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue