[]
Gets or sets the JSON serializer used for custom cell values in JSON import and export.
Be aware of thread safety and JSON element injection problems when you are implementing the IJsonSerializer.
public static IJsonSerializer ValueJsonSerializer { get; set; }
Public Shared Property ValueJsonSerializer As IJsonSerializer
| Type | Description |
|---|---|
| IJsonSerializer | The IJsonSerializer which will be used in all workbooks. |
class ValueWithUnit
{
public double Amount;
public string Unit;
}
class ValueSerializer : IJsonSerializer
{
public string Serialize(object value)
{
ValueWithUnit data = (ValueWithUnit)value;
return Newtonsoft.Json.JsonConvert.SerializeObject(data);
}
public object Deserialize(string json)
{
return Newtonsoft.Json.JsonConvert.DeserializeObject<ValueWithUnit>(json);
}
}
IJsonSerializer serializer = new ValueSerializer();
Workbook.ValueJsonSerializer = serializer;
IJsonSerializer currentSerializer = Workbook.ValueJsonSerializer;