| | |
| | | return result;
|
| | | }
|
| | |
|
| | | //json格式: {"1":{"1":1,"2":2},"2":{"3":3,"4":4}}
|
| | | public static Dictionary<int, Dictionary<int, int>> ParseDictInDict(string jsonStr)
|
| | | {
|
| | | if (jsonStr == "{}" || string.IsNullOrEmpty(jsonStr))
|
| | | {
|
| | | return new Dictionary<int, Dictionary<int, int>>();
|
| | | }
|
| | | var dict = JsonMapper.ToObject<Dictionary<string, Dictionary<string, int>>>(jsonStr);
|
| | | Dictionary<int, Dictionary<int, int>> result = new Dictionary<int, Dictionary<int, int>>();
|
| | |
|
| | | foreach (var item in dict)
|
| | | {
|
| | | Dictionary<int, int> subDict = new Dictionary<int, int>();
|
| | | foreach (var subItem in item.Value)
|
| | | {
|
| | | subDict[int.Parse(subItem.Key)] = subItem.Value;
|
| | | }
|
| | | result[int.Parse(item.Key)] = subDict;
|
| | | }
|
| | | |
| | | return result;
|
| | | }
|
| | |
|
| | | //万分率转为每个id对应的概率 [[万分概率,id1],[万分概率,id2]]
|
| | | public static Dictionary<int, int> GetRateDict(int[][] rateArray)
|