Skip to content

Commit

Permalink
Merge pull request #2292 from markisaa/constToString
Browse files Browse the repository at this point in the history
Issue 13015 - std.json.JSONValue's toString is now const
  • Loading branch information
DmitryOlshansky committed Jul 5, 2014
2 parents 6883e0e + 0d3507f commit d97dc15
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions std/json.d
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d97dc15

Please sign in to comment.