[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.Workbook.ValueJsonSerializer

ValueJsonSerializer Property

ValueJsonSerializer

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.

Declaration
public static IJsonSerializer ValueJsonSerializer { get; set; }
Public Shared Property ValueJsonSerializer As IJsonSerializer
Property Value
Type Description
IJsonSerializer

The IJsonSerializer which will be used in all workbooks.

Examples
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;