[]
Represents a serializer and deserializer for custom types used in JSON import and export.
Implement this interface to convert application-specific objects to JSON strings and to reconstruct those objects when a workbook is converted to or from JSON. This interface is typically used with TagJsonSerializer or ValueJsonSerializer.
public interface IJsonSerializer
Public Interface IJsonSerializer
public class SimpleJsonSerializer : IJsonSerializer
{
public string Serialize(object value)
{
return System.Text.Json.JsonSerializer.Serialize(new { value });
}
public object Deserialize(string json)
{
return System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, object>>(json);
}
}
IJsonSerializer serializer = new SimpleJsonSerializer();
Workbook.ValueJsonSerializer = serializer;
| Name | Description |
|---|---|
| Deserialize(string) | Deserializes a JSON string to an object. Implement this method to reconstruct an application-specific object from its JSON representation. The concrete return type depends on the serializer implementation and how the JSON content is interpreted. |
| Serialize(object) | Serializes an object to a JSON string. Implement this method to convert a custom value into JSON text that can be used during JSON import and export. The returned string should be compatible with the corresponding Deserialize(string) implementation. |