Assuming you returned Dictionary<string, string>from your controller action:
public ActionResult GetDetails()
{
var result = new Dictionary<string, string>
{
{ "key1", "value1" },
{ "key2", "value2" },
{ "key3", "value3" },
};
return Json(result, JsonRequestBehavior.AllowGet);
}
which will cause the following JSON to be sent over the cable:
{"key1":"value1","key2":"value2","key3":"value3"}
, javascript Array, , . javascript .
AJAX:
function MakeControllerMethodCallFunction_Success(dictionaryObject) {
for (var key in dictionaryObject) {
if (dictionaryObject.hasOwnProperty(key)) {
var value = dictionaryObject[key];
alert(key + " -> " + value);
}
}
}
, Dictionary<string, SomeModel>, javascript: value.SomeProperty.