Skip to content
JsonBlock

DoesShorthandExist

bool DoesShorthandExist(const std::string shorthand, const char delimiter = '.') const
bool DoesShorthandExist(const std::string shorthand, const std::string delimiter) const

Shorthand function.
A shorthand function is designed to make working with deep, nested json structures easier and faster.

Does the same as DoesExist(), but with a shorthand label.

If you, for whatever reason, don't want to use the '.' delimiter, you can specify a custom one. It can even be a string!


Examples:

Json:
{
    "id": {
        "names": {
            "firstname": "Joseph"
        }
    }
}
C++:
// returns true
myJsonBlock.DoesShorthandExist("id.names.firstname");

// returns also true
myJsonBlock.DoesShorthandExist("id.names");

// returns false
myJsonBlock.DoesShorthandExist("id.names.power_drill");
Custom delimiter (C++):
// returns true
myJsonBlock.DoesShorthandExist("id->names->firstname", "->");
// returns true
myJsonBlock.DoesShorthandExist("id/names/firstname", '/');
// returns false, because the delimiter parameter is missing!
myJsonBlock.DoesShorthandExist("id->names->firstname");