c# - Sending a dictionary of javascript parameters to MVC Controller via JSON -


i'm using third party library , cant change way posts data mvc 5 controller.

i cant figure out how setup model receive data.

the json follows...

{  "expiration":"2015-06-14t21:02:52.969z",  "conditions":[    {"acl":"private"},    {"bucket":"anyoldbucket"},    {"content-type":"application/pdf"},    {"success_action_status":"200"},    {"key":"somekey"}   ] } 

i tried setting model this...

public class awssignaturerequestviewmodel {     public datetime expiration { get; set; }     public dictionary<string, string> conditions { get; set; }  } 

the expiration date correctly filled out, , right number of conditions keys dictionary numbers (indexes) , values null

any suggestions?

if model strict, need make objects every sub objects. if have dynamic model, can read raw string request , parse json.net.

public actionresult test(string model) {   request.inputstream.seek(0, seekorigin.begin);   string jsondata = new streamreader(request.inputstream).readtoend();   var dynamicobject = jobject.parse(jsondata);   ... } 

dynamicobject contains of json.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -