mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 12:23:15 +00:00
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:
parent
f5ff796970
commit
9889d170b9
|
@ -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())
|
||||
|
|
Loading…
Reference in a new issue