holdtom
因为你想要速度,这可能会也可能不会让你感兴趣unsafe public static string Convert(string input){ fixed (char* pInput = input) { char* p1, p2, len = pInput + input.Length; for (p1 = p2 = pInput + 1; p2 < len; p1++, p2++) *p1 = *(p2 - 1) == '"' && *p2 == '_' ? char.ToUpper(*++p2) : *p2; return input.Substring(0, (int)(p1 - pInput)); }}它只是简单地替换"_<char>为"<Upper case char>在我的电脑上它可以做到 445 Mb 1.8 秒样本输入{ "menu":{ "id":"_file", "value":"_file", "popup":{ "menuitem":[ { "value":"_new", "onclick":"_createNewDoc()" }, { "value":"_open", "onclick":"_openDoc()" }, { "value":"_close", "onclick":"_closeDoc()" } ] } }}输出{ "menu":{ "id":"File", "value":"File", "popup":{ "menuitem":[ { "value":"New", "onclick":"CreateNewDoc()" }, { "value":"Open", "onclick":"OpenDoc()" }, { "value":"Close", "onclick":"CloseDoc()" } ] } }}