pub struct KvToJson<'a> { /* private fields */ }
Expand description

JSON rendering of key-value pairs

When formatted with "{}", this produces a single-line compact JSON rendering of the key-value pairs.

Implementations

Create a KvToJson ready to be formatted. The output will have commas between items, but not at the start or end. A list of key-value pairs would normally be surrounded by { and } in JSON, but since this type may be used in other contexts, e.g. to extend a JSON object, only the plain key-value pairs are output.

prefix and suffix are two strings which are output before and after the key-value pairs, but only if the list of key-value pairs is non-empty. So, for example, passing "," and "" would be suitable for extending a larger JSON object that you’re already building up. Or alternatively, passing ",\"kv\":{" and "}" would allow an optional "kv" item to be added to a larger JSON object, but only if there is key-value data.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.