简体   繁体   English

如何将Javascript数组解析为C#List / Dictionary

[英]How to parse Javascript array to c# List/Dictionary

I have 2 separate system, My first system will return a java script like bellow 我有2个独立的系统,我的第一个系统将返回一个Java脚本,例如波纹管

var st=[];
var at=[];
var bt=[];
var ht=[];
ht[0]=['015',5,'33087443','23','50','22','x'];
ht[1]=['018',5,'45648783','53','10','20','z'];

My second system will grab all this java script to process it and store into database , is that any parser or any way to allow me to separate all this different var st , at, bt, ht into a list or dictionary ? 我的第二个系统将抓取所有这些Java脚本来对其进行处理并将其存储到数据库中,是任何解析器或任何允许我将所有这些不同的var st , at, bt, ht分为列表或字典的方法?

my expected outcome is list/dictionary : - (so that it easily for me to access the data) 我的预期结果是列表/字典:-(以便我轻松访问数据)

List/Dictionary st = //All that array value
List/Dictionary at = //All that array value
List/Dictionary ht = //All that array value

If you can, I would recommend altering your system to return JSON data, not javascript as it is more easily consumed by .Net. 如果可以的话,我建议您更改系统以返回JSON数据,而不是JavaScript数据,因为.Net更容易使用它。 Using Javascript will require that you either use the outdated MSScript control or JInt. 使用Javascript将要求您使用过时的MSScript控件或JInt。 Speaking from experience, neither of which are very pleasant to work with. 从经验上来讲,两者都不是一件令人愉快的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM