| | |
| | | }
|
| | |
|
| | | s = s.Replace(" ", string.Empty);
|
| | | if (!userDataRegex.IsMatch(s))
|
| | | {
|
| | |
|
| | |
|
| | | var dict = JsonMapper.ToObject<Dictionary<string, string[]>>(s);
|
| | |
|
| | | if (dict == null || dict.Count == 0)
|
| | | return null;
|
| | | }
|
| | | else
|
| | |
|
| | | Dictionary<int, List<int>> result = new Dictionary<int, List<int>>();
|
| | |
|
| | | foreach (var item in dict)
|
| | | {
|
| | | Dictionary<int, List<int>> dics = new Dictionary<int, List<int>>();
|
| | | foreach (Match match in userDataRegex.Matches(s))
|
| | | List<int> list = new List<int>();
|
| | | for (int i = 0; i < item.Value.Length; i++)
|
| | | {
|
| | | int id = int.Parse(match.Groups[1].Value);
|
| | | string str = match.Groups[2].Value;
|
| | | string[] vals = str.Split(',');
|
| | | List<int> list = new List<int>();
|
| | | for (int i = 0; i < vals.Length; i++)
|
| | | {
|
| | | int intval = int.Parse(vals[i].Replace('\'', ' '));
|
| | | list.Add(intval);
|
| | | }
|
| | | if (!dics.ContainsKey(id))
|
| | | {
|
| | | dics.Add(id, list);
|
| | | }
|
| | | list.Add(int.Parse(item.Value[i]));
|
| | | }
|
| | | return dics;
|
| | | if (list.Count != 0)
|
| | | result[int.Parse(item.Key)] = list;
|
| | | }
|
| | |
|
| | | return result;
|
| | |
|
| | | //if (!userDataRegex.IsMatch(s))
|
| | | //{
|
| | | // return null;
|
| | | //}
|
| | | //else
|
| | | //{
|
| | | // Dictionary<int, List<int>> dics = new Dictionary<int, List<int>>();
|
| | | // foreach (Match match in userDataRegex.Matches(s))
|
| | | // {
|
| | | // int id = int.Parse(match.Groups[1].Value);
|
| | | // string str = match.Groups[2].Value;
|
| | | // string[] vals = str.Split(',');
|
| | | // List<int> list = new List<int>();
|
| | | // for (int i = 0; i < vals.Length; i++)
|
| | | // {
|
| | | // int intval = int.Parse(vals[i].Replace('\'', ' '));
|
| | | // list.Add(intval);
|
| | | // }
|
| | | // if (!dics.ContainsKey(id))
|
| | | // {
|
| | | // dics.Add(id, list);
|
| | | // }
|
| | | // }
|
| | | // return dics;
|
| | | //}
|
| | | }
|
| | |
|
| | | public static Dictionary<int, List<int>> ParseJsonDict(string jsonStr)
|