could anybody tell me how to serialize and deserialize only part of array tools[] without Func delegate where:
public class Tool
{
public Tool()
{
lastUse = 1;
running = false;
}
public Func<int> action;
public bool running;
public int lastUse;
}
public static Tool[] tools = new Tool[] { new Tool(), new Tool(), new Tool(),new Tool()};
Thanks in advance for any responses.
One thing you can do is take advantage of the DataContract and DataMember attributes to only serialize the data you want.
The result without the attributes:
With the attributes:
This works with both Json.NET and DataContractJsonSerialize.
What I like about this approach is it let’s you keep standard C# property naming conventions, but still output “correctly cased” JSON.
will output