mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:37:44 +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
1 changed files with 7 additions and 0 deletions
|
@ -63,6 +63,13 @@ public:
|
||||||
template<typename Builder>
|
template<typename Builder>
|
||||||
void serialize(Builder&) const;
|
void serialize(Builder&) const;
|
||||||
|
|
||||||
|
String as_string_or(const String& alternative)
|
||||||
|
{
|
||||||
|
if (is_string())
|
||||||
|
return as_string();
|
||||||
|
return alternative;
|
||||||
|
}
|
||||||
|
|
||||||
String to_string() const
|
String to_string() const
|
||||||
{
|
{
|
||||||
if (is_string())
|
if (is_string())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue