Json file entry looks like this: settings.json
{
"MyJson": {
"Machine": "machine",
"Date": "date",
"Time": "time",
"Milli": "milli"
}
}
And I am using below code to convert this json to dictionary in C#
public static Dictionary<string,string> myDict{ get; private set; }
var configuration = new ConfigurationBuilder().AddJsonFile("settings.json", false, true).Build();
myDict = configuration.GetSection("MyJson").Get<Dictionary<string, string>>();
This code is storing key based sorted entries in myDict. I want to maintain the insertion order in myDict. Is there are solution for this?
2
Answers
There is no any practical use in order maintaining. If you need it for some weird reason, add to each item an order number like this, for example