I would like to skip some dictionary value that same as a default value.
Here is the simplified code of that dictionary
public Dictionary<int, Item> allItems;
public class Item
{
public bool IsSelected;
public List<string> SelectionInfo;
}
So, as of right now, my JSON output looks like this:
"allItems": {
"0": {
"IsSelected": true,
"SelectionInfo": [
"yes",
"maybe",
"no"
]
},
"1": {
"IsSelected": false,
"SelectionInfo": []
}
}
I want to skip the "1" But don't just entirely skip it, at least keep the key so it can be restored at later. and have 0 and 1 on the dictionary
Like this?
"allItems": {
"0": {
"IsSelected": true,
"SelectionInfo": [
"yes",
"maybe",
"no"
]
},
"1": { }
}
I was looking around and found out that you can use JsonConverter. But my case JSON
tool is on the other Project (Utility.Please.TurnToJson(item);
) and I want to keep it consistent and use only one JSON across all projects. Maybe if JsonConverter is the only option, at least provide me the solution on how to pass the custom JsonConverter to that project.
///somewhat like this?
Utility.Please.TurnToJson(item, new List<object>(){
typeof(Custom1),
typeof(Custom2)
});