日期:2014-05-17 浏览次数:21037 次
{"open":70, "high":100, "low":50, "close": 90}
int open = 0, high = 0, low = 0, close = 0;
string str = @"{""open"":70, ""high"":100, ""low"":50, ""close"":90}";
string[] strs = str.Substring(1, str.Length - 2).Split(',').SelectMany(c => c.Split(':')).Where((c, i) => i % 2 != 0).ToArray();
open = int.Parse(strs[0].Trim());
high = int.Parse(strs[1].Trim());
low = int.Parse(strs[2].Trim());
close = int.Parse(strs[3].Trim());
Console.WriteLine("open={0} high={1} low={2} close={3}", open, high, low, close);
不是你写的吧,这是Json格式用的时候序列化就行了。另外js也可解析这种格式就是var obj=eval("("+Json+")"); alert(obj.open);alert(obj.heih);alert(obj.low);