[英]Format of Javascript Object of Arrays to save as C# dictionary for WCF
I want to save a javascript object of arrays into a dictionary with a list of string in C# through ajax. 我想通过ajax将数组的javascript对象保存到带有C#中的字符串列表的字典中。 But I can't figure out the format needed for the object in javascript.
但是我无法弄清楚javascript中对象所需的格式。
My javascript object is in the format: 我的javascript对象的格式为:
{
"foo" : ["abc", "def", "ghi"],
"foo2": ["123", "456", "789"],
}
But the C# data member ends up holding an empty object. 但是C#数据成员最终持有一个空对象。
I've also tried 我也尝试过
[
{"foo" : ["abc", "def", "ghi"]},
{"foo2": ["123", "456", "789"]},
]
My C# datamember is 我的C#数据成员是
[DataMember]
public Dictionary<string, List<string>> theDictionary;
I have no trouble with saving list of strings or saving other simple javascript objects if I've created the corresponding C# class. 如果创建了相应的C#类,则可以轻松保存字符串列表或保存其他简单的javascript对象。 Any idea what format is needed?
知道需要什么格式吗?
so I found my answer here : Pass a javascript map to json wcf service 所以我在这里找到了答案: 将javascript映射传递给json wcf服务
The format I needed was 我需要的格式是
[
{ Key: "foo" , Value: ["abc", "def", "ghi"]},
{ Key: "foo2", Value: ["123", "456", "789"]},
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.