I want to save a javascript object of arrays into a dictionary with a list of string in C# through ajax. But I can't figure out the format needed for the object in javascript.
My javascript object is in the format:
{
"foo" : ["abc", "def", "ghi"],
"foo2": ["123", "456", "789"],
}
But the C# data member ends up holding an empty object.
I've also tried
[
{"foo" : ["abc", "def", "ghi"]},
{"foo2": ["123", "456", "789"]},
]
My C# datamember is
[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. Any idea what format is needed?
so I found my answer here : Pass a javascript map to json wcf service
The format I needed was
[
{ Key: "foo" , Value: ["abc", "def", "ghi"]},
{ Key: "foo2", Value: ["123", "456", "789"]},
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.