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?

1

1 Answer 1

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"]}, 
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.