diff options
Diffstat (limited to 'source/core')
-rw-r--r-- | source/core/StarJson.cpp | 6 | ||||
-rw-r--r-- | source/core/StarJson.hpp | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/source/core/StarJson.cpp b/source/core/StarJson.cpp index 7cf1cda..15b7092 100644 --- a/source/core/StarJson.cpp +++ b/source/core/StarJson.cpp @@ -868,6 +868,12 @@ String Json::printJson(int pretty, bool sort) const { return repr(pretty, sort); } +String Json::printString() const { + if (type() == Type::String) + return *m_data.get<StringConstPtr>(); + return repr(); +} + std::ostream& operator<<(std::ostream& os, Json const& v) { outputUtf8Json(v, std::ostream_iterator<char>(os), 0, false); return os; diff --git a/source/core/StarJson.hpp b/source/core/StarJson.hpp index b58b9a0..fb4c229 100644 --- a/source/core/StarJson.hpp +++ b/source/core/StarJson.hpp @@ -253,6 +253,8 @@ public: String repr(int pretty = 0, bool sort = false) const; // Prints JSON object or array only (only top level types allowed by JSON) String printJson(int pretty = 0, bool sort = false) const; + // Same but avoids quotation marks if this is a string + String printString() const; // operator== and operator!= compare for exact equality with all types, and // additionally equality with numeric conversion with Int <-> Float |