Skip to content
JsonBlock

ShorthandRemove

void ShorthandRemove(const std::string shorthand, const char delimiter = '.')
void ShorthandRemove(const std::string shorthand, const std::string delimiter)

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

Does the same as Remove(), 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!

Shorthand validity

If the shorthand is invalid, a JsonShorthandInvalidException will be thrown.
The validity of a shorthand depends on the function it is given to. In this case, a shorthand is invalid, if

  • The shorthand is empty ("")
  • At least one path segment does not exist
  • At least one non-last path segment is not of type JSON

Examples:

Json:
{
    "id": {
        "names": {
            "firstname": "Joseph"
        }
    }
}
C++:
myJsonBlock.ShorthandRemove("id.names.firstname");
Custom delimiter (C++):
myJsonBlock.ShorthandRemove("id->names->firstname", "->");
myJsonBlock.ShorthandRemove("id/names/firstname", '/');
Resulting json:
{
    "id": {
        "names": { }
    }
}