using Newtonsoft.Json; using System.Collections.Generic; using System.Text.RegularExpressions; public static class GameTool { //用于获取多层级Dictionary中的value public static string GetValueAtPath(Dictionary root, string[] path) { Dictionary current = root; int count = 0; foreach (string key in path) { string rawValue = current[key].ToString(); rawValue = Regex.Replace(rawValue, @"[\r\n]", ""); if (count == path.Length - 1) { return rawValue; } Dictionary value = JsonConvert.DeserializeObject>(rawValue); current = value; count++; } return null; } }