This commit is contained in:
nlohmann
2026-07-08 18:19:46 +00:00
parent 9a231845c2
commit 279d757031
758 changed files with 56489 additions and 503 deletions
+40
View File
@@ -0,0 +1,40 @@
# <small>nlohmann::json_pointer::</small>back
```cpp
const string_t& back() const;
```
Return the last reference token.
## Return value
Last reference token.
## Exceptions
Throws [out_of_range.405](../../home/exceptions.md#jsonexceptionout_of_range405) if the JSON pointer has no parent.
## Complexity
Constant.
## Examples
??? example
The example shows the usage of `back`.
```cpp
--8<-- "examples/json_pointer__back.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__back.output"
```
## Version history
- Added in version 3.6.0.
- Changed return type to `string_t` in version 3.11.0.
File diff suppressed because one or more lines are too long
+55
View File
@@ -0,0 +1,55 @@
# nlohmann::json_pointer::back
```
const string_t& back() const;
```
Return the last reference token.
## Return value
Last reference token.
## Exceptions
Throws [out_of_range.405](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range405) if the JSON pointer has no parent.
## Complexity
Constant.
## Examples
Example
The example shows the usage of `back`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON Pointers
json::json_pointer ptr1("/foo");
json::json_pointer ptr2("/foo/0");
// call empty()
std::cout << "last reference token of \"" << ptr1 << "\" is \"" << ptr1.back() << "\"\n"
<< "last reference token of \"" << ptr2 << "\" is \"" << ptr2.back() << "\"" << std::endl;
}
```
Output:
```
last reference token of "/foo" is "foo"
last reference token of "/foo/0" is "0"
```
## Version history
- Added in version 3.6.0.
- Changed return type to `string_t` in version 3.11.0.
+39
View File
@@ -0,0 +1,39 @@
# <small>nlohmann::json_pointer::</small>empty
```cpp
bool empty() const noexcept;
```
Return whether the pointer points to the root document.
## Return value
`#!cpp true` iff the JSON pointer points to the root document.
## Exception safety
No-throw guarantee: this function never throws exceptions.
## Complexity
Constant.
## Examples
??? example
The example shows the result of `empty` for different JSON Pointers.
```cpp
--8<-- "examples/json_pointer__empty.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__empty.output"
```
## Version history
Added in version 3.6.0.
File diff suppressed because one or more lines are too long
+61
View File
@@ -0,0 +1,61 @@
# nlohmann::json_pointer::empty
```
bool empty() const noexcept;
```
Return whether the pointer points to the root document.
## Return value
`true` iff the JSON pointer points to the root document.
## Exception safety
No-throw guarantee: this function never throws exceptions.
## Complexity
Constant.
## Examples
Example
The example shows the result of `empty` for different JSON Pointers.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON Pointers
json::json_pointer ptr0;
json::json_pointer ptr1("");
json::json_pointer ptr2("/foo");
json::json_pointer ptr3("/foo/0");
// call empty()
std::cout << std::boolalpha
<< "\"" << ptr0 << "\": " << ptr0.empty() << '\n'
<< "\"" << ptr1 << "\": " << ptr1.empty() << '\n'
<< "\"" << ptr2 << "\": " << ptr2.empty() << '\n'
<< "\"" << ptr3 << "\": " << ptr3.empty() << std::endl;
}
```
Output:
```
"": true
"": true
"/foo": false
"/foo/0": false
```
## Version history
Added in version 3.6.0.
+39
View File
@@ -0,0 +1,39 @@
# <small>nlohmann::json_pointer::</small>front
```cpp
const string_t& front() const;
```
Return the first reference token.
## Return value
First reference token.
## Exceptions
Throws [out_of_range.405](../../home/exceptions.md#jsonexceptionout_of_range405) if the JSON pointer has no parent.
## Complexity
Constant.
## Examples
??? example
The example shows the usage of `front`.
```cpp
--8<-- "examples/json_pointer__front.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__front.output"
```
## Version history
- Added in version 3.12.x.
File diff suppressed because one or more lines are too long
+54
View File
@@ -0,0 +1,54 @@
# nlohmann::json_pointer::front
```
const string_t& front() const;
```
Return the first reference token.
## Return value
First reference token.
## Exceptions
Throws [out_of_range.405](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range405) if the JSON pointer has no parent.
## Complexity
Constant.
## Examples
Example
The example shows the usage of `front`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON Pointers
json::json_pointer ptr1("/foo");
json::json_pointer ptr2("/foo/0");
// call empty()
std::cout << "first reference token of \"" << ptr1 << "\" is \"" << ptr1.front() << "\"\n"
<< "first reference token of \"" << ptr2 << "\" is \"" << ptr2.front() << "\"" << std::endl;
}
```
Output:
```
first reference token of "/foo" is "foo"
first reference token of "/foo/0" is "foo"
```
## Version history
- Added in version 3.12.x.
File diff suppressed because one or more lines are too long
+51
View File
@@ -0,0 +1,51 @@
# nlohmann::json_pointer
```
template<typename RefStringType>
class json_pointer;
```
A JSON pointer defines a string syntax for identifying a specific value within a JSON document. It can be used with functions [`at`](https://json.nlohmann.me/api/basic_json/at/index.md) and [`operator[]`](https://json.nlohmann.me/api/basic_json/operator%5B%5D/index.md). Furthermore, JSON pointers are the base for JSON patches.
## Template parameters
`RefStringType` : the string type used for the reference tokens making up the JSON pointer
Deprecation
For backwards compatibility `RefStringType` may also be a specialization of [`basic_json`](https://json.nlohmann.me/api/basic_json/index.md) in which case `string_t` will be deduced as [`basic_json::string_t`](https://json.nlohmann.me/api/basic_json/string_t/index.md). This feature is deprecated and may be removed in a future major version.
## Member types
- [**string_t**](https://json.nlohmann.me/api/json_pointer/string_t/index.md) - the string type used for the reference tokens
## Member functions
- [(constructor)](https://json.nlohmann.me/api/json_pointer/json_pointer/index.md)
- [**to_string**](https://json.nlohmann.me/api/json_pointer/to_string/index.md) - return a string representation of the JSON pointer
- [**operator string_t**](https://json.nlohmann.me/api/json_pointer/operator_string_t/index.md) - return a string representation of the JSON pointer
- [**operator==**](https://json.nlohmann.me/api/json_pointer/operator_eq/index.md) - compare: equal
- [**operator!=**](https://json.nlohmann.me/api/json_pointer/operator_ne/index.md) - compare: not equal
- [**operator/=**](https://json.nlohmann.me/api/json_pointer/operator_slasheq/index.md) - append to the end of the JSON pointer
- [**operator/**](https://json.nlohmann.me/api/json_pointer/operator_slash/index.md) - create JSON Pointer by appending
- [**parent_pointer**](https://json.nlohmann.me/api/json_pointer/parent_pointer/index.md) - returns the parent of this JSON pointer
- [**pop_back**](https://json.nlohmann.me/api/json_pointer/pop_back/index.md) - remove the last reference token
- [**back**](https://json.nlohmann.me/api/json_pointer/back/index.md) - return last reference token
- [**push_back**](https://json.nlohmann.me/api/json_pointer/push_back/index.md) - append an unescaped token at the end of the pointer
- [**pop_front**](https://json.nlohmann.me/api/json_pointer/pop_front/index.md) - remove the first reference token
- [**front**](https://json.nlohmann.me/api/json_pointer/front/index.md) - return first reference token
- [**push_front**](https://json.nlohmann.me/api/json_pointer/push_front/index.md) - append an unescaped token at the start of the pointer
- [**empty**](https://json.nlohmann.me/api/json_pointer/empty/index.md) - return whether the pointer points to the root document
## Literals
- [**operator""\_json_pointer**](https://json.nlohmann.me/api/operator_literal_json_pointer/index.md) - user-defined string literal for JSON pointers
## See also
- [RFC 6901](https://datatracker.ietf.org/doc/html/rfc6901)
## Version history
- Added in version 2.0.0.
- Changed template parameter from `basic_json` to string type in version 3.11.0.
+41
View File
@@ -0,0 +1,41 @@
# <small>nlohmann::json_pointer::</small>json_pointer
```cpp
explicit json_pointer(const string_t& s = "");
```
Create a JSON pointer according to the syntax described in
[Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3).
## Parameters
`s` (in)
: string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value
## Exceptions
- Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is
nonempty and does not begin with a slash (`/`); see example below.
- Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON
pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below.
## Examples
??? example
The example shows the construction several valid JSON pointers as well as the exceptional behavior.
```cpp
--8<-- "examples/json_pointer.cpp"
```
Output:
```json
--8<-- "examples/json_pointer.output"
```
## Version history
- Added in version 2.0.0.
- Changed type of `s` to `string_t` in version 3.11.0.
File diff suppressed because one or more lines are too long
+85
View File
@@ -0,0 +1,85 @@
# nlohmann::json_pointer::json_pointer
```
explicit json_pointer(const string_t& s = "");
```
Create a JSON pointer according to the syntax described in [Section 3 of RFC6901](https://tools.ietf.org/html/rfc6901#section-3).
## Parameters
`s` (in) : string representing the JSON pointer; if omitted, the empty string is assumed which references the whole JSON value
## Exceptions
- Throws [parse_error.107](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error107) if the given JSON pointer `s` is nonempty and does not begin with a slash (`/`); see example below.
- Throws [parse_error.108](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below.
## Examples
Example
The example shows the construction several valid JSON pointers as well as the exceptional behavior.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// correct JSON pointers
json::json_pointer p1;
json::json_pointer p2("");
json::json_pointer p3("/");
json::json_pointer p4("//");
json::json_pointer p5("/foo/bar");
json::json_pointer p6("/foo/bar/-");
json::json_pointer p7("/foo/~0");
json::json_pointer p8("/foo/~1");
// error: JSON pointer does not begin with a slash
try
{
json::json_pointer p9("foo");
}
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
// error: JSON pointer uses escape symbol ~ not followed by 0 or 1
try
{
json::json_pointer p10("/foo/~");
}
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
// error: JSON pointer uses escape symbol ~ not followed by 0 or 1
try
{
json::json_pointer p11("/foo/~3");
}
catch (const json::parse_error& e)
{
std::cout << e.what() << '\n';
}
}
```
Output:
```
[json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'foo'
[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
[json.exception.parse_error.108] parse error: escape character '~' must be followed with '0' or '1'
```
## Version history
- Added in version 2.0.0.
- Changed type of `s` to `string_t` in version 3.11.0.
+113
View File
@@ -0,0 +1,113 @@
# <small>nlohmann::json_pointer::</small>operator==
```cpp
// until C++20
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept; // (1)
template<typename RefStringTypeLhs, typename StringType>
bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs); // (2)
template<typename RefStringTypeRhs, typename StringType>
bool operator==(
const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs); // (2)
// since C++20
class json_pointer {
template<typename RefStringTypeRhs>
bool operator==(
const json_pointer<RefStringTypeRhs>& rhs) const noexcept; // (1)
bool operator==(const string_t& rhs) const; // (2)
};
```
1. Compares two JSON pointers for equality by comparing their reference tokens.
2. Compares a JSON pointer and a string or a string and a JSON pointer for equality by converting the string to a JSON
pointer and comparing the JSON pointers according to 1.
## Template parameters
`RefStringTypeLhs`, `RefStringTypeRhs`
: the string type of the left-hand side or right-hand side JSON pointer, respectively
`StringType`
: the string type derived from the `json_pointer` operand ([`json_pointer::string_t`](string_t.md))
## Parameters
`lhs` (in)
: first value to consider
`rhs` (in)
: second value to consider
## Return value
whether the values `lhs`/`*this` and `rhs` are equal
## Exception safety
1. No-throw guarantee: this function never throws exceptions.
2. Strong exception safety: if an exception occurs, the original value stays intact.
## Exceptions
1. (none)
2. The function can throw the following exceptions:
- Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is
nonempty and does not begin with a slash (`/`); see example below.
- Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON
pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below.
## Complexity
Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference
tokens.
## Notes
!!! warning "Deprecation"
Overload 2 is deprecated and will be removed in a future major version release.
## Examples
??? example "Example: (1) Comparing JSON pointers"
The example demonstrates comparing JSON pointers.
```cpp
--8<-- "examples/json_pointer__operator__equal.cpp"
```
Output:
```
--8<-- "examples/json_pointer__operator__equal.output"
```
??? example "Example: (2) Comparing JSON pointers and strings"
The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception.
```cpp
--8<-- "examples/json_pointer__operator__equal_stringtype.cpp"
```
Output:
```
--8<-- "examples/json_pointer__operator__equal_stringtype.output"
```
## Version history
1. Added in version 2.1.0. Added C++20 member functions in version 3.11.2.
2. Added for backward compatibility and deprecated in version 3.11.2.
File diff suppressed because one or more lines are too long
+160
View File
@@ -0,0 +1,160 @@
# nlohmann::json_pointer::operator==
```
// until C++20
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept; // (1)
template<typename RefStringTypeLhs, typename StringType>
bool operator==(
const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs); // (2)
template<typename RefStringTypeRhs, typename StringType>
bool operator==(
const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs); // (2)
// since C++20
class json_pointer {
template<typename RefStringTypeRhs>
bool operator==(
const json_pointer<RefStringTypeRhs>& rhs) const noexcept; // (1)
bool operator==(const string_t& rhs) const; // (2)
};
```
1. Compares two JSON pointers for equality by comparing their reference tokens.
1. Compares a JSON pointer and a string or a string and a JSON pointer for equality by converting the string to a JSON pointer and comparing the JSON pointers according to 1.
## Template parameters
`RefStringTypeLhs`, `RefStringTypeRhs` : the string type of the left-hand side or right-hand side JSON pointer, respectively
`StringType` : the string type derived from the `json_pointer` operand ([`json_pointer::string_t`](https://json.nlohmann.me/api/json_pointer/string_t/index.md))
## Parameters
`lhs` (in) : first value to consider
`rhs` (in) : second value to consider
## Return value
whether the values `lhs`/`*this` and `rhs` are equal
## Exception safety
1. No-throw guarantee: this function never throws exceptions.
1. Strong exception safety: if an exception occurs, the original value stays intact.
## Exceptions
1. (none)
1. The function can throw the following exceptions:
1. Throws [parse_error.107](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error107) if the given JSON pointer `s` is nonempty and does not begin with a slash (`/`); see example below.
1. Throws [parse_error.108](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below.
## Complexity
Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference tokens.
## Notes
Deprecation
Overload 2 is deprecated and will be removed in a future major version release.
## Examples
Example: (1) Comparing JSON pointers
The example demonstrates comparing JSON pointers.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON pointers
json::json_pointer ptr0;
json::json_pointer ptr1("");
json::json_pointer ptr2("/foo");
// compare JSON pointers
std::cout << std::boolalpha
<< "\"" << ptr0 << "\" == \"" << ptr0 << "\": " << (ptr0 == ptr0) << '\n'
<< "\"" << ptr0 << "\" == \"" << ptr1 << "\": " << (ptr0 == ptr1) << '\n'
<< "\"" << ptr1 << "\" == \"" << ptr2 << "\": " << (ptr1 == ptr2) << '\n'
<< "\"" << ptr2 << "\" == \"" << ptr2 << "\": " << (ptr2 == ptr2) << std::endl;
}
```
Output:
```
"" == "": true
"" == "": true
"" == "/foo": false
"/foo" == "/foo": true
```
Example: (2) Comparing JSON pointers and strings
The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception.
```
#include <exception>
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON pointers
json::json_pointer ptr0;
json::json_pointer ptr1("");
json::json_pointer ptr2("/foo");
// different strings
std::string str0("");
std::string str1("/foo");
std::string str2("bar");
// compare JSON pointers and strings
std::cout << std::boolalpha
<< "\"" << ptr0 << "\" == \"" << str0 << "\": " << (ptr0 == str0) << '\n'
<< "\"" << str0 << "\" == \"" << ptr1 << "\": " << (str0 == ptr1) << '\n'
<< "\"" << ptr2 << "\" == \"" << str1 << "\": " << (ptr2 == str1) << std::endl;
try
{
std::cout << "\"" << str2 << "\" == \"" << ptr2 << "\": " << (str2 == ptr2) << std::endl;
}
catch (const json::parse_error& ex)
{
std::cout << ex.what() << std::endl;
}
}
```
Output:
```
"" == "": true
"" == "": true
"/foo" == "/foo": true
"bar" == "/foo": [json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'bar'
```
## Version history
1. Added in version 2.1.0. Added C++20 member functions in version 3.11.2.
1. Added for backward compatibility and deprecated in version 3.11.2.
+109
View File
@@ -0,0 +1,109 @@
# <small>nlohmann::json_pointer::</small>operator!=
```cpp
// until C++20
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept; // (1)
template<typename RefStringTypeLhs, typename StringType>
bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs); // (2)
template<typename RefStringTypeRhs, typename StringType>
bool operator!=(
const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs); // (2)
```
1. Compares two JSON pointers for inequality by comparing their reference tokens.
2. Compares a JSON pointer and a string or a string and a JSON pointer for inequality by converting the string to a
JSON pointer and comparing the JSON pointers according to 1.
## Template parameters
`RefStringTypeLhs`, `RefStringTypeRhs`
: the string type of the left-hand side or right-hand side JSON pointer, respectively
`StringType`
: the string type derived from the `json_pointer` operand ([`json_pointer::string_t`](string_t.md))
## Parameters
`lhs` (in)
: first value to consider
`rhs` (in)
: second value to consider
## Return value
whether the values `lhs`/`*this` and `rhs` are not equal
## Exception safety
1. No-throw guarantee: this function never throws exceptions.
2. Strong exception safety: if an exception occurs, the original value stays intact.
## Exceptions
1. (none)
2. The function can throw the following exceptions:
- Throws [parse_error.107](../../home/exceptions.md#jsonexceptionparse_error107) if the given JSON pointer `s` is
nonempty and does not begin with a slash (`/`); see example below.
- Throws [parse_error.108](../../home/exceptions.md#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON
pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below.
## Complexity
Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference
tokens.
## Notes
!!! note "Operator overload resolution"
Since C++20 overload resolution will consider the _rewritten candidate_ generated from
[`operator==`](operator_eq.md).
!!! warning "Deprecation"
Overload 2 is deprecated and will be removed in a future major version release.
## Examples
??? example "Example: (1) Comparing JSON pointers"
The example demonstrates comparing JSON pointers.
```cpp
--8<-- "examples/json_pointer__operator__notequal.cpp"
```
Output:
```
--8<-- "examples/json_pointer__operator__notequal.output"
```
??? example "Example: (2) Comparing JSON pointers and strings"
The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception.
```cpp
--8<-- "examples/json_pointer__operator__notequal_stringtype.cpp"
```
Output:
```
--8<-- "examples/json_pointer__operator__notequal_stringtype.output"
```
## Version history
1. Added in version 2.1.0.
2. Added for backward compatibility and deprecated in version 3.11.2.
File diff suppressed because one or more lines are too long
+154
View File
@@ -0,0 +1,154 @@
# nlohmann::json_pointer::operator!=
```
// until C++20
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
const json_pointer<RefStringTypeRhs>& rhs) noexcept; // (1)
template<typename RefStringTypeLhs, typename StringType>
bool operator!=(
const json_pointer<RefStringTypeLhs>& lhs,
const StringType& rhs); // (2)
template<typename RefStringTypeRhs, typename StringType>
bool operator!=(
const StringType& lhs,
const json_pointer<RefStringTypeRhs>& rhs); // (2)
```
1. Compares two JSON pointers for inequality by comparing their reference tokens.
1. Compares a JSON pointer and a string or a string and a JSON pointer for inequality by converting the string to a JSON pointer and comparing the JSON pointers according to 1.
## Template parameters
`RefStringTypeLhs`, `RefStringTypeRhs` : the string type of the left-hand side or right-hand side JSON pointer, respectively
`StringType` : the string type derived from the `json_pointer` operand ([`json_pointer::string_t`](https://json.nlohmann.me/api/json_pointer/string_t/index.md))
## Parameters
`lhs` (in) : first value to consider
`rhs` (in) : second value to consider
## Return value
whether the values `lhs`/`*this` and `rhs` are not equal
## Exception safety
1. No-throw guarantee: this function never throws exceptions.
1. Strong exception safety: if an exception occurs, the original value stays intact.
## Exceptions
1. (none)
1. The function can throw the following exceptions:
1. Throws [parse_error.107](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error107) if the given JSON pointer `s` is nonempty and does not begin with a slash (`/`); see example below.
1. Throws [parse_error.108](https://json.nlohmann.me/home/exceptions/#jsonexceptionparse_error108) if a tilde (`~`) in the given JSON pointer `s` is not followed by `0` (representing `~`) or `1` (representing `/`); see example below.
## Complexity
Constant if `lhs` and `rhs` differ in the number of reference tokens, otherwise linear in the number of reference tokens.
## Notes
Operator overload resolution
Since C++20 overload resolution will consider the *rewritten candidate* generated from [`operator==`](https://json.nlohmann.me/api/json_pointer/operator_eq/index.md).
Deprecation
Overload 2 is deprecated and will be removed in a future major version release.
## Examples
Example: (1) Comparing JSON pointers
The example demonstrates comparing JSON pointers.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON pointers
json::json_pointer ptr0;
json::json_pointer ptr1("");
json::json_pointer ptr2("/foo");
// compare JSON pointers
std::cout << std::boolalpha
<< "\"" << ptr0 << "\" != \"" << ptr0 << "\": " << (ptr0 != ptr0) << '\n'
<< "\"" << ptr0 << "\" != \"" << ptr1 << "\": " << (ptr0 != ptr1) << '\n'
<< "\"" << ptr1 << "\" != \"" << ptr2 << "\": " << (ptr1 != ptr2) << '\n'
<< "\"" << ptr2 << "\" != \"" << ptr2 << "\": " << (ptr2 != ptr2) << std::endl;
}
```
Output:
```
"" != "": false
"" != "": false
"" != "/foo": true
"/foo" != "/foo": false
```
Example: (2) Comparing JSON pointers and strings
The example demonstrates comparing JSON pointers and strings, and when doing so may raise an exception.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON pointers
json::json_pointer ptr0;
json::json_pointer ptr1("");
json::json_pointer ptr2("/foo");
// different strings
std::string str0("");
std::string str1("/foo");
std::string str2("bar");
// compare JSON pointers and strings
std::cout << std::boolalpha
<< "\"" << ptr0 << "\" != \"" << str0 << "\": " << (ptr0 != str0) << '\n'
<< "\"" << str0 << "\" != \"" << ptr1 << "\": " << (str0 != ptr1) << '\n'
<< "\"" << ptr2 << "\" != \"" << str1 << "\": " << (ptr2 != str1) << std::endl;
try
{
std::cout << "\"" << str2 << "\" != \"" << ptr2 << "\": " << (str2 != ptr2) << std::endl;
}
catch (const json::parse_error& ex)
{
std::cout << ex.what() << std::endl;
}
}
```
Output:
```
"" != "": false
"" != "": false
"/foo" != "/foo": false
"bar" != "/foo": [json.exception.parse_error.107] parse error at byte 1: JSON pointer must be empty or begin with '/' - was: 'bar'
```
## Version history
1. Added in version 2.1.0.
1. Added for backward compatibility and deprecated in version 3.11.2.
+64
View File
@@ -0,0 +1,64 @@
# <small>nlohmann::json_pointer::</small>operator/
```cpp
// (1)
json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs);
// (2)
json_pointer operator/(const json_pointer& lhs, string_t token);
// (3)
json_pointer operator/(const json_pointer& lhs, std::size_t array_idx);
```
1. create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
2. create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
3. create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
## Parameters
`lhs` (in)
: JSON pointer
`rhs` (in)
: JSON pointer to append
`token` (in)
: reference token to append
`array_idx` (in)
: array index to append
## Return value
1. a new JSON pointer with `rhs` appended to `lhs`
2. a new JSON pointer with unescaped `token` appended to `lhs`
3. a new JSON pointer with `array_idx` appended to `lhs`
## Complexity
1. Linear in the length of `lhs` and `rhs`.
2. Linear in the length of `lhs`.
3. Linear in the length of `lhs`.
## Examples
??? example
The example shows the usage of `operator/`.
```cpp
--8<-- "examples/json_pointer__operator_add_binary.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__operator_add_binary.output"
```
## Version history
1. Added in version 3.6.0.
2. Added in version 3.6.0. Changed type of `token` to `string_t` in version 3.11.0.
3. Added in version 3.6.0.
File diff suppressed because one or more lines are too long
+80
View File
@@ -0,0 +1,80 @@
# nlohmann::json_pointer::operator/
```
// (1)
json_pointer operator/(const json_pointer& lhs, const json_pointer& rhs);
// (2)
json_pointer operator/(const json_pointer& lhs, string_t token);
// (3)
json_pointer operator/(const json_pointer& lhs, std::size_t array_idx);
```
1. create a new JSON pointer by appending the right JSON pointer at the end of the left JSON pointer
1. create a new JSON pointer by appending the unescaped token at the end of the JSON pointer
1. create a new JSON pointer by appending the array-index-token at the end of the JSON pointer
## Parameters
`lhs` (in) : JSON pointer
`rhs` (in) : JSON pointer to append
`token` (in) : reference token to append
`array_idx` (in) : array index to append
## Return value
1. a new JSON pointer with `rhs` appended to `lhs`
1. a new JSON pointer with unescaped `token` appended to `lhs`
1. a new JSON pointer with `array_idx` appended to `lhs`
## Complexity
1. Linear in the length of `lhs` and `rhs`.
1. Linear in the length of `lhs`.
1. Linear in the length of `lhs`.
## Examples
Example
The example shows the usage of `operator/`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON pointer
json::json_pointer ptr("/foo");
// append a JSON Pointer
std::cout << "\"" << ptr / json::json_pointer("/bar/baz") << "\"\n";
// append a string
std::cout << "\"" << ptr / "fob" << "\"\n";
// append an array index
std::cout << "\"" << ptr / 42 << "\"" << std::endl;
}
```
Output:
```
"/foo/bar/baz"
"/foo/fob"
"/foo/42"
```
## Version history
1. Added in version 3.6.0.
1. Added in version 3.6.0. Changed type of `token` to `string_t` in version 3.11.0.
1. Added in version 3.6.0.
+61
View File
@@ -0,0 +1,61 @@
# <small>nlohmann::json_pointer::</small>operator/=
```cpp
// (1)
json_pointer& operator/=(const json_pointer& ptr);
// (2)
json_pointer& operator/=(string_t token);
// (3)
json_pointer& operator/=(std::size_t array_idx)
```
1. append another JSON pointer at the end of this JSON pointer
2. append an unescaped reference token at the end of this JSON pointer
3. append an array index at the end of this JSON pointer
## Parameters
`ptr` (in)
: JSON pointer to append
`token` (in)
: reference token to append
`array_idx` (in)
: array index to append
## Return value
1. JSON pointer with `ptr` appended
2. JSON pointer with `token` appended without escaping `token`
3. JSON pointer with `array_idx` appended
## Complexity
1. Linear in the length of `ptr`.
2. Amortized constant.
3. Amortized constant.
## Examples
??? example
The example shows the usage of `operator/=`.
```cpp
--8<-- "examples/json_pointer__operator_add.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__operator_add.output"
```
## Version history
1. Added in version 3.6.0.
2. Added in version 3.6.0. Changed type of `token` to `string_t` in version 3.11.0.
3. Added in version 3.6.0.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,83 @@
# nlohmann::json_pointer::operator/=
```
// (1)
json_pointer& operator/=(const json_pointer& ptr);
// (2)
json_pointer& operator/=(string_t token);
// (3)
json_pointer& operator/=(std::size_t array_idx)
```
1. append another JSON pointer at the end of this JSON pointer
1. append an unescaped reference token at the end of this JSON pointer
1. append an array index at the end of this JSON pointer
## Parameters
`ptr` (in) : JSON pointer to append
`token` (in) : reference token to append
`array_idx` (in) : array index to append
## Return value
1. JSON pointer with `ptr` appended
1. JSON pointer with `token` appended without escaping `token`
1. JSON pointer with `array_idx` appended
## Complexity
1. Linear in the length of `ptr`.
1. Amortized constant.
1. Amortized constant.
## Examples
Example
The example shows the usage of `operator/=`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create a JSON pointer
json::json_pointer ptr("/foo");
std::cout << "\"" << ptr << "\"\n";
// append a JSON Pointer
ptr /= json::json_pointer("/bar/baz");
std::cout << "\"" << ptr << "\"\n";
// append a string
ptr /= "fob";
std::cout << "\"" << ptr << "\"\n";
// append an array index
ptr /= 42;
std::cout << "\"" << ptr << "\"" << std::endl;
}
```
Output:
```
"/foo"
"/foo/bar/baz"
"/foo/bar/baz/fob"
"/foo/bar/baz/fob/42"
```
## Version history
1. Added in version 3.6.0.
1. Added in version 3.6.0. Changed type of `token` to `string_t` in version 3.11.0.
1. Added in version 3.6.0.
+52
View File
@@ -0,0 +1,52 @@
# <small>nlohmann::json_pointer::</small>operator string_t
```cpp
operator string_t() const
```
Return a string representation of the JSON pointer.
## Return value
A string representation of the JSON pointer
## Possible implementation
```cpp
operator string_t() const
{
return to_string();
}
```
## Notes
!!! warning "Deprecation"
This function is deprecated in favor of [`to_string`](to_string.md) and will be removed in a future major version
release.
## Examples
??? example
The example shows how JSON Pointers can be implicitly converted to strings.
```cpp
--8<-- "examples/json_pointer__operator_string_t.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__operator_string_t.output"
```
## See also
- [string_t](../basic_json/string_t.md)- type for strings
## Version history
- Since version 2.0.0.
- Changed type to `string_t` and deprecated in version 3.11.0.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,70 @@
# nlohmann::json_pointer::operator string_t
```
operator string_t() const
```
Return a string representation of the JSON pointer.
## Return value
A string representation of the JSON pointer
## Possible implementation
```
operator string_t() const
{
return to_string();
}
```
## Notes
Deprecation
This function is deprecated in favor of [`to_string`](https://json.nlohmann.me/api/json_pointer/to_string/index.md) and will be removed in a future major version release.
## Examples
Example
The example shows how JSON Pointers can be implicitly converted to strings.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON Pointers
json::json_pointer ptr1("/foo/0");
json::json_pointer ptr2("/a~1b");
// implicit conversion to string
std::string s;
s += ptr1;
s += "\n";
s += ptr2;
std::cout << s << std::endl;
}
```
Output:
```
/foo/0
/a~1b
```
## See also
- [string_t](https://json.nlohmann.me/api/basic_json/string_t/index.md)- type for strings
## Version history
- Since version 2.0.0.
- Changed type to `string_t` and deprecated in version 3.11.0.
+44
View File
@@ -0,0 +1,44 @@
# <small>nlohmann::json_pointer::</small>parent_pointer
```cpp
json_pointer parent_pointer() const;
```
Returns the parent of this JSON pointer.
## Return value
Parent of this JSON pointer; in case this JSON pointer is the root, the root itself is returned.
## Exception safety
No-throw guarantee: this function never throws exceptions.
## Complexity
Linear in the length of the JSON pointer.
## Examples
??? example
The example shows the result of `parent_pointer` for different JSON Pointers.
```cpp
--8<-- "examples/json_pointer__parent_pointer.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__parent_pointer.output"
```
## See also
- [pop_back](pop_back.md) remove the last reference token
- [back](back.md) return the last reference token
## Version history
Added in version 3.6.0.
File diff suppressed because one or more lines are too long
+63
View File
@@ -0,0 +1,63 @@
# nlohmann::json_pointer::parent_pointer
```
json_pointer parent_pointer() const;
```
Returns the parent of this JSON pointer.
## Return value
Parent of this JSON pointer; in case this JSON pointer is the root, the root itself is returned.
## Exception safety
No-throw guarantee: this function never throws exceptions.
## Complexity
Linear in the length of the JSON pointer.
## Examples
Example
The example shows the result of `parent_pointer` for different JSON Pointers.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON Pointers
json::json_pointer ptr1("");
json::json_pointer ptr2("/foo");
json::json_pointer ptr3("/foo/0");
// call parent_pointer()
std::cout << std::boolalpha
<< "parent of \"" << ptr1 << "\" is \"" << ptr1.parent_pointer() << "\"\n"
<< "parent of \"" << ptr2 << "\" is \"" << ptr2.parent_pointer() << "\"\n"
<< "parent of \"" << ptr3 << "\" is \"" << ptr3.parent_pointer() << "\"" << std::endl;
}
```
Output:
```
parent of "" is ""
parent of "/foo" is ""
parent of "/foo/0" is "/foo"
```
## See also
- [pop_back](https://json.nlohmann.me/api/json_pointer/pop_back/index.md) remove the last reference token
- [back](https://json.nlohmann.me/api/json_pointer/back/index.md) return the last reference token
## Version history
Added in version 3.6.0.
+35
View File
@@ -0,0 +1,35 @@
# <small>nlohmann::json_pointer::</small>pop_back
```cpp
void pop_back();
```
Remove the last reference token.
## Exceptions
Throws [out_of_range.405](../../home/exceptions.md#jsonexceptionout_of_range405) if the JSON pointer has no parent.
## Complexity
Constant.
## Examples
??? example
The example shows the usage of `pop_back`.
```cpp
--8<-- "examples/json_pointer__pop_back.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__pop_back.output"
```
## Version history
Added in version 3.6.0.
File diff suppressed because one or more lines are too long
+58
View File
@@ -0,0 +1,58 @@
# nlohmann::json_pointer::pop_back
```
void pop_back();
```
Remove the last reference token.
## Exceptions
Throws [out_of_range.405](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range405) if the JSON pointer has no parent.
## Complexity
Constant.
## Examples
Example
The example shows the usage of `pop_back`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create empty JSON Pointer
json::json_pointer ptr("/foo/bar/baz");
std::cout << "\"" << ptr << "\"\n";
// call pop_back()
ptr.pop_back();
std::cout << "\"" << ptr << "\"\n";
ptr.pop_back();
std::cout << "\"" << ptr << "\"\n";
ptr.pop_back();
std::cout << "\"" << ptr << "\"\n";
}
```
Output:
```
"/foo/bar/baz"
"/foo/bar"
"/foo"
""
```
## Version history
Added in version 3.6.0.
+35
View File
@@ -0,0 +1,35 @@
# <small>nlohmann::json_pointer::</small>pop_front
```cpp
void pop_front();
```
Remove the first reference token.
## Exceptions
Throws [out_of_range.405](../../home/exceptions.md#jsonexceptionout_of_range405) if the JSON pointer has no parent.
## Complexity
Linear in the number of reference tokens in the `json_pointer`.
## Examples
??? example
The example shows the usage of `pop_front`.
```cpp
--8<-- "examples/json_pointer__pop_front.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__pop_front.output"
```
## Version history
- Added in version 3.12.x.
File diff suppressed because one or more lines are too long
+58
View File
@@ -0,0 +1,58 @@
# nlohmann::json_pointer::pop_front
```
void pop_front();
```
Remove the first reference token.
## Exceptions
Throws [out_of_range.405](https://json.nlohmann.me/home/exceptions/#jsonexceptionout_of_range405) if the JSON pointer has no parent.
## Complexity
Linear in the number of reference tokens in the `json_pointer`.
## Examples
Example
The example shows the usage of `pop_front`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create empty JSON Pointer
json::json_pointer ptr("/foo/bar/baz");
std::cout << "\"" << ptr << "\"\n";
// call pop_front()
ptr.pop_front();
std::cout << "\"" << ptr << "\"\n";
ptr.pop_front();
std::cout << "\"" << ptr << "\"\n";
ptr.pop_front();
std::cout << "\"" << ptr << "\"\n";
}
```
Output:
```
"/foo/bar/baz"
"/bar/baz"
"/baz"
""
```
## Version history
- Added in version 3.12.x.
+39
View File
@@ -0,0 +1,39 @@
# <small>nlohmann::json_pointer::</small>push_back
```cpp
void push_back(const string_t& token);
void push_back(string_t&& token);
```
Append an unescaped token at the end of the reference pointer.
## Parameters
`token` (in)
: token to add
## Complexity
Amortized constant.
## Examples
??? example
The example shows the result of `push_back` for different JSON Pointers.
```cpp
--8<-- "examples/json_pointer__push_back.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__push_back.output"
```
## Version history
- Added in version 3.6.0.
- Changed type of `token` to `string_t` in version 3.11.0.
File diff suppressed because one or more lines are too long
+61
View File
@@ -0,0 +1,61 @@
# nlohmann::json_pointer::push_back
```
void push_back(const string_t& token);
void push_back(string_t&& token);
```
Append an unescaped token at the end of the reference pointer.
## Parameters
`token` (in) : token to add
## Complexity
Amortized constant.
## Examples
Example
The example shows the result of `push_back` for different JSON Pointers.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create empty JSON Pointer
json::json_pointer ptr;
std::cout << "\"" << ptr << "\"\n";
// call push_back()
ptr.push_back("foo");
std::cout << "\"" << ptr << "\"\n";
ptr.push_back("0");
std::cout << "\"" << ptr << "\"\n";
ptr.push_back("bar");
std::cout << "\"" << ptr << "\"\n";
}
```
Output:
```
""
"/foo"
"/foo/0"
"/foo/0/bar"
```
## Version history
- Added in version 3.6.0.
- Changed type of `token` to `string_t` in version 3.11.0.
+38
View File
@@ -0,0 +1,38 @@
# <small>nlohmann::json_pointer::</small>push_front
```cpp
void push_front(const string_t& token);
void push_front(string_t&& token);
```
Append an unescaped token at the start of the reference pointer.
## Parameters
`token` (in)
: token to add
## Complexity
Linear in the number of reference tokens in the `json_pointer`.
## Examples
??? example
The example shows the result of `push_front` for different JSON Pointers.
```cpp
--8<-- "examples/json_pointer__push_front.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__push_front.output"
```
## Version history
- Added in version 3.12.x.
File diff suppressed because one or more lines are too long
+60
View File
@@ -0,0 +1,60 @@
# nlohmann::json_pointer::push_front
```
void push_front(const string_t& token);
void push_front(string_t&& token);
```
Append an unescaped token at the start of the reference pointer.
## Parameters
`token` (in) : token to add
## Complexity
Linear in the number of reference tokens in the `json_pointer`.
## Examples
Example
The example shows the result of `push_front` for different JSON Pointers.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// create empty JSON Pointer
json::json_pointer ptr;
std::cout << "\"" << ptr << "\"\n";
// call push_front()
ptr.push_front("foo");
std::cout << "\"" << ptr << "\"\n";
ptr.push_front("0");
std::cout << "\"" << ptr << "\"\n";
ptr.push_front("bar");
std::cout << "\"" << ptr << "\"\n";
}
```
Output:
```
""
"/foo"
"/0/foo"
"/bar/0/foo"
```
## Version history
- Added in version 3.12.x.
+28
View File
@@ -0,0 +1,28 @@
# <small>nlohmann::json_pointer::</small>string_t
```cpp
using string_t = RefStringType;
```
The string type used for the reference tokens making up the JSON pointer.
See [`basic_json::string_t`](../basic_json/string_t.md) for more information.
## Examples
??? example
The example shows the type `string_t` and its relation to `basic_json::string_t`.
```cpp
--8<-- "examples/json_pointer__string_t.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__string_t.output"
```
## Version history
- Added in version 3.11.0.
File diff suppressed because one or more lines are too long
+42
View File
@@ -0,0 +1,42 @@
# nlohmann::json_pointer::string_t
```
using string_t = RefStringType;
```
The string type used for the reference tokens making up the JSON pointer.
See [`basic_json::string_t`](https://json.nlohmann.me/api/basic_json/string_t/index.md) for more information.
## Examples
Example
The example shows the type `string_t` and its relation to `basic_json::string_t`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
json::json_pointer::string_t s = "This is a string.";
std::cout << s << std::endl;
std::cout << std::boolalpha << std::is_same<json::json_pointer::string_t, json::string_t>::value << std::endl;
}
```
Output:
```
This is a string.
true
```
## Version history
- Added in version 3.11.0.
+40
View File
@@ -0,0 +1,40 @@
# <small>nlohmann::json_pointer::</small>to_string
```cpp
string_t to_string() const;
```
Return a string representation of the JSON pointer.
## Return value
A string representation of the JSON pointer
## Notes
For each JSON pointer `ptr`, it holds:
```cpp
ptr == json_pointer(ptr.to_string());
```
## Examples
??? example
The example shows the result of `to_string`.
```cpp
--8<-- "examples/json_pointer__to_string.cpp"
```
Output:
```json
--8<-- "examples/json_pointer__to_string.output"
```
## Version history
- Since version 2.0.0.
- Changed return type to `string_t` in version 3.11.0.
File diff suppressed because one or more lines are too long
+84
View File
@@ -0,0 +1,84 @@
# nlohmann::json_pointer::to_string
```
string_t to_string() const;
```
Return a string representation of the JSON pointer.
## Return value
A string representation of the JSON pointer
## Notes
For each JSON pointer `ptr`, it holds:
```
ptr == json_pointer(ptr.to_string());
```
## Examples
Example
The example shows the result of `to_string`.
```
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// different JSON Pointers
json::json_pointer ptr1("");
json::json_pointer ptr2("/foo");
json::json_pointer ptr3("/foo/0");
json::json_pointer ptr4("/");
json::json_pointer ptr5("/a~1b");
json::json_pointer ptr6("/c%d");
json::json_pointer ptr7("/e^f");
json::json_pointer ptr8("/g|h");
json::json_pointer ptr9("/i\\j");
json::json_pointer ptr10("/k\"l");
json::json_pointer ptr11("/ ");
json::json_pointer ptr12("/m~0n");
std::cout << "\"" << ptr1.to_string() << "\"\n"
<< "\"" << ptr2.to_string() << "\"\n"
<< "\"" << ptr3.to_string() << "\"\n"
<< "\"" << ptr4.to_string() << "\"\n"
<< "\"" << ptr5.to_string() << "\"\n"
<< "\"" << ptr6.to_string() << "\"\n"
<< "\"" << ptr7.to_string() << "\"\n"
<< "\"" << ptr8.to_string() << "\"\n"
<< "\"" << ptr9.to_string() << "\"\n"
<< "\"" << ptr10.to_string() << "\"\n"
<< "\"" << ptr11.to_string() << "\"\n"
<< "\"" << ptr12.to_string() << "\"" << std::endl;
}
```
Output:
```
""
"/foo"
"/foo/0"
"/"
"/a~1b"
"/c%d"
"/e^f"
"/g|h"
"/i\j"
"/k"l"
"/ "
"/m~0n"
```
## Version history
- Since version 2.0.0.
- Changed return type to `string_t` in version 3.11.0.