Expand description
Provides low-level, granular, token-based JSON string processing.
This module offers the most fundamental building blocks for both escaping and
unescaping. It provides iterators, UnescapeTokens and EscapeTokens,
that walk a byte/string slice and yield tokens. This approach is highly flexible
and composable, allowing consumers to handle the data in a zero-copy,
streaming fashion for literal (non-processed) parts.
§Unescaping
The UnescapeTokens iterator yields UnescapedTokens, separating literal
byte slices from single unescaped chars. This ensures that in the case of an
error (e.g., an invalid escape sequence), all preceding valid literal parts have
already been successfully yielded.
§Escaping
The EscapeTokens iterator yields EscapedTokens, separating literal
string slices from the &'static str representation of an escaped character.
This allows for efficient, allocation-free iteration over a string to produce
its JSON-escaped form.
Structs§
- Display
Unescape Tokens - A wrapper struct for implementing
fmt::Displayon anUnescapeTokensiterator. - Display
Unescaped Token - Helper struct for safely displaying an
DisplayUnescapedToken. - Escape
Tokens - An iterator over a string that yields
EscapedTokens. - Unescape
Tokens - An iterator over a byte slice that yields
UnescapedTokens.
Enums§
- Escaped
Token - A token representing a piece of an escaped JSON string.
- Unescaped
Token - A token representing a piece of an unescaped JSON string.
Functions§
- escape_
str - Creates an iterator that yields tokens of an escaped JSON string.
- unescape
- Creates an iterator that yields tokens of an unescaped JSON string.