0

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?

Manish Parakhiya
  • 3,732
  • 3
  • 22
  • 25
roverred
  • 1,841
  • 5
  • 29
  • 46
  • possible duplicate of [Javascript Object pass to ASP.NET Handler](http://stackoverflow.com/questions/13424687/javascript-object-pass-to-asp-net-handler) – Ben Smith Sep 17 '14 at 00:51

1 Answers1

0

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"]}, 
]
Community
  • 1
  • 1
roverred
  • 1,841
  • 5
  • 29
  • 46