asp.net mvc - C# MVC 4 Json request -
I am posting a JSON object to a controller action:
$ Data: "Jason", Data: {Name: "John Doe", Phone: "2323454543", Skill: {code: ". Php ", design:" Photoshop "}}}); How do I map this data to a key-value pair object? In PHP, these are invisibly mapped to an associative array. I would like to be able to use properties like this:
SomeDynamicType data = ... // To generate some JSN Data String Code here Skills = data.skills.code; // code skills = "php" I am not interested in model binding because these values do not conform to any model - they are arbitrary. <
your own Jason in the Axax call:
Data: {json: JSON.stringify ({name: "John doo", phone: "2323454543", Skill: {code: "php", Design: " Photoshop "}}}} and access your desired assets in your controller:
[http post] Public JSRSalt action (string jsn) { Dynamic Data = NewtonSoft.Jason.Jason Convert.DearariLiz Object> Dynamic> (JSN); String Code Skills = Data. Skills.code; ... Code Skil "Php" string.
Newtonsoft Json Library .NET is available in 4, if I remember right.
Comments
Post a Comment