2015-10-20 72 views
0

我需要將密鑰對值字典發佈到REST API。我使用NancyFx框架綁定參數將字典傳遞給REST API

服務器端屬性:

public Dictionary<string, string> foo { get; set; } 

客戶端代碼:

  var bar = []; 
      bar["one"] = "First"; 
      bar["two"] = "Second"; 

      var UserModel = { 
       someotherpar: "abc", 
       foo: bar 
      }; 
      $.ajax({ 
       url: 'myEndpoint', 
       type: 'POST', 
       contentType: 'application/json', 
       data: JSON.stringify(UserModel), 
       success: function (data, textStatus, jqXHR) { 

        }  
      }); 

回答

0

這是可能的使用SortedList的,而不是解釋。