Class StringDeserializer
A deserializer for converting byte[] to strings using a specified character encoding.
public class StringDeserializer : IDeserializer<string>
- Inheritance
-
StringDeserializer
- Implements
- Inherited Members
Fields
SolaceDeserializerStringEncoding
Configuration property key for specifying the string encoding. The value can be a string encoding name (e.g., "UTF-8", "UTF-16") or an Encoding instance.
public const string SolaceDeserializerStringEncoding = "solace.deserializer.string.encoding"
Field Value
Methods
Configure(IDictionary<string, object>)
Configures this StringDeserializer with the given properties.
public void Configure(IDictionary<string, object> properties)
Parameters
propertiesIDictionary<string, object>A dictionary of configuration properties.
Remarks
The default encoding is UTF-8.
Supported configuration properties:
- SolaceDeserializerStringEncoding The character encoding to use for deserialization. Can be a string encoding name or an Encoding instance.
Exceptions
- ArgumentNullException
Thrown when
propertiesis null.- ArgumentException
Thrown when the encoding value is not a valid string or Encoding, or when the specified encoding name is not supported.
Deserialize(string, ReadOnlySpan<byte>, IDictionary<string, object>)
Deserializes the given byte payload to a string using the configured character encoding.
public string Deserialize(string destinationName, ReadOnlySpan<byte> payload, IDictionary<string, object> headers = null)
Parameters
destinationNamestringThe name of the destination (not used in this implementation).
payloadReadOnlySpan<byte>The byte payload to deserialize.
headersIDictionary<string, object>Optional headers (not used in this implementation).
Returns
- string
The deserialized string. Returns an empty string if the payload is empty or null.
Remarks
The default encoding is UTF-8.
Note: ReadOnlySpan is non-nullable; null payloads become empty spans and return an empty string.