JsonValue: Add as_string_or(String)

Return the contained string if the value *is* a string, otherwise it
returns the alternative string passed in the parameter.
This commit is contained in:
Andreas Kling 2019-08-07 22:03:25 +02:00
commit 9889d170b9
Notes: sideshowbarker 2024-07-19 12:50:02 +09:00

View file

@ -63,6 +63,13 @@ public:
template<typename Builder>
void serialize(Builder&) const;
String as_string_or(const String& alternative)
{
if (is_string())
return as_string();
return alternative;
}
String to_string() const
{
if (is_string())