SpaceSeparatedValuesConverter Class
A custom JSON converter that handles arrays of strings, converting them to and from space-separated values in JSON.
public class SpaceSeparatedValuesConverter : System.Text.Json.Serialization.JsonConverter<string[]>Inheritance System.Object → System.Text.Json.Serialization.JsonConverter → System.Text.Json.Serialization.JsonConverter<System.String[]> → SpaceSeparatedValuesConverter
Methods
SpaceSeparatedValuesConverter.Read(Utf8JsonReader, Type, JsonSerializerOptions) Method
Reads a JSON string containing space-separated values and converts it to an array of strings.
public override string[]? Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options);Parameters
reader System.Text.Json.Utf8JsonReader
The reader to read JSON from.
typeToConvert System.Type
The type of object to convert to. Expected to be an array of strings.
options System.Text.Json.JsonSerializerOptions
Options for the serializer.
Returns
System.String[]
An array of strings parsed from the space-separated values in the JSON string.
SpaceSeparatedValuesConverter.Write(Utf8JsonWriter, string[], JsonSerializerOptions) Method
Writes an array of strings to JSON as a single string with values separated by spaces.
public override void Write(System.Text.Json.Utf8JsonWriter writer, string[] value, System.Text.Json.JsonSerializerOptions options);Parameters
writer System.Text.Json.Utf8JsonWriter
The writer to write JSON to.
value System.String[]
The array of strings to write.
options System.Text.Json.JsonSerializerOptions
Options for the serializer.