File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
include/simdjson/generic/ondemand Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,17 @@ class value {
163163 * Important: a value should be consumed once. Calling get_string() twice on the same value
164164 * is an error.
165165 *
166+ * In some instances, you may want to allow replacement of invalid Unicode sequences.
167+ * You may do so by passing the allow_replacement parameter as true. In the following
168+ * example, the string "431924697b\udff0L\u0001Y" is not valid Unicode. By passing true
169+ * to get_string, we allow the replacement of the invalid Unicode sequences with the Unicode
170+ * replacement character (U+FFFD).
171+ *
172+ * simdjson::ondemand::parser parser;
173+ * auto json = R"({"deviceId":"431924697b\udff0L\u0001Y"})"_padded;
174+ * simdjson::ondemand::document doc = parser.iterate(json);
175+ * auto view = doc["deviceId"].get_string(true);
176+ *
166177 * @returns An UTF-8 string. The string is stored in the parser and will be invalidated the next
167178 * time it parses a document or when it is destroyed.
168179 * @returns INCORRECT_TYPE if the JSON value is not a string.
You can’t perform that action at this time.
0 commit comments