本人想解析网页里面的数组,有什么优雅的办法或第三方组件也行

.Net技术 码拜 8年前 (2017-04-11) 1616次浏览
和讯网的数据提前预处理改成[[***],[***]]格式之后,
再用new JavaScriptSerializer().Deserialize<List<object>>(arrayText)来得到List<object>
感觉这样不太优雅,有没有什么代码或组件能直接解析下面的数据,而不用提前对字符串做处理呢?
dataArr = [
[“603816″,”N顾家”,35.51,44.00,24.66,29.59,35.51,29.59,606.04,2145536,0.07,24.01,0.00],
[“603887″,”城地股份”,25.58,10.02,23.25,25.58,25.58,25.58,182.11,465837,0.07,0.00,0.00],
[“603777″,”来伊份”,20.33,10.01,18.48,20.33,20.33,20.33,128.89,262033,0.02,0.00,0.00],
[“603738″,”泰晶科技”,45.28,10.01,41.16,45.28,45.28,45.28,190.86,864214,0.11,0.00,0.00],
[“603313″,”恒康家居”,24.41,10.00,22.19,24.41,24.41,24.41,158.71,387411,0.03,0.00,0.00],
[“603189″,”网达软件”,43.67,10.00,39.70,43.67,43.67,43.67,6457.52,28199990,1.17,0.00,0.00],
[“600500″,”中化国际”,10.57,9.99,9.61,9.61,10.57,9.52,576628.41,596498090,3.35,10.93,4.81],
[“603421″,”鼎信通讯”,26.87,9.99,24.43,26.87,26.87,26.87,104,279448,0.02,0.00,0.00]];StockListPage.GetData(dataArr,134,”2016-10-16 09:25:10″);
本人对js不太熟,谢谢
解决方案

40

        static void Main(string[] args)
        {
            var s = @"
dataArr = [
["603816","N顾家",35.51,44.00,24.66,29.59,35.51,29.59,606.04,2145536,0.07,24.01,0.00],
["603887","城地股份",25.58,10.02,23.25,25.58,25.58,25.58,182.11,465837,0.07,0.00,0.00],
["603777","来伊份",20.33,10.01,18.48,20.33,20.33,20.33,128.89,262033,0.02,0.00,0.00],
["603738","泰晶科技",45.28,10.01,41.16,45.28,45.28,45.28,190.86,864214,0.11,0.00,0.00],
["603313","恒康家居",24.41,10.00,22.19,24.41,24.41,24.41,158.71,387411,0.03,0.00,0.00],
["603189","网达软件",43.67,10.00,39.70,43.67,43.67,43.67,6457.52,28199990,1.17,0.00,0.00],
["600500","中化国际",10.57,9.99,9.61,9.61,10.57,9.52,576628.41,596498090,3.35,10.93,4.81],
["603421","鼎信通讯",26.87,9.99,24.43,26.87,26.87,26.87,104,279448,0.02,0.00,0.00]];StockListPage.GetData(dataArr,134,""2016-10-16 09:25:10"");";
            var m = Regex.Match(s, @"\[.+\]", RegexOptions.Singleline);
            var a = JArray.Parse(m.Value);
            foreach (var r in a)
            {
                Console.WriteLine(string.Join(" | ", r));
            }
        }

本人想解析网页里面的数组,有什么优雅的办法或第三方组件也行


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明本人想解析网页里面的数组,有什么优雅的办法或第三方组件也行
喜欢 (0)
[1034331897@qq.com]
分享 (0)