From 0d3507f6361b8206abacd0962d3af2993a7c905c Mon Sep 17 00:00:00 2001 From: Mark Isaacson Date: Tue, 1 Jul 2014 11:23:18 -0700 Subject: [PATCH] std.json.JSONValue toString is now const --- std/json.d | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/std/json.d b/std/json.d index 266dba186..671c25592 100644 --- a/std/json.d +++ b/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