Skip to content

Commit 7414d9f

Browse files
committed
Doc update
1 parent 765a51c commit 7414d9f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/ref/json/as.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ Output:
8383
1,2,3,4
8484
```
8585

86+
#### Use string_view to access the actual memory that's being used to hold a string
87+
88+
You can use `j.as<jsoncons::string_view>()`, e.g.
89+
```c++
90+
json j = json::parse("\"Hello World\"");
91+
auto sv = j.as<jsoncons::string_view>();
92+
```
93+
`jsoncons::string_view` supports the member functions of `std::string_view`, including `data()` and `size()`.
94+
95+
If your compiler supports `std::string_view`, you can also use `j.as<std::string_view>()`.
96+
8697
#### Accessing a `json` byte string as a byte string
8798
```c++
8899
std::vector<uint8_t> u = {'H','e','l','l','o'};

0 commit comments

Comments
 (0)