I have an array of JSON objects, some of which contain key / value pairs, for which this value is an array.
Example:
var jsonArray = [{ "key1":"value1", "key2":["value21", "value22"]},
{ "key1":"value3", "key2":["value41", "value42"]}];
EDIT: Randomly used curly braces instead of brackets.
I am trying to send this via AJAX to an ASP.NET web service using jQuery:
$.ajax({
type: "post",
url: "example.asmx/SomeFunction"
data: "{ 'items': '" + JSON.stringify(jsonArray) + "' }",
contentType: "application/json;charset=utf-8",
dataType: "json"
});
Is this the right way to send data? Also, what type of data do I need in a parameter SomeFunction
to accept and parse JSON data?
source
share