Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to parse dynamic object in mvc?
    primarykey
    data
    text
    <p>I am working on ASP.NET MVC4.0.</p> <p>My string is posting like this from view :-</p> <pre><code>[{"name":"AddressNumber","value":"1"},{"name":"OrganizationProd","value":""},{"name":"ClientId","value":""},{"name":"ProductId","value":""},{"name":"TaxId1","value":""},{"name":"TaxId2","value":""},{"name":"LaborID","value":"0"}] </code></pre> <p>And below is my controller's action method for that,which is receiving the input :-</p> <pre><code>[AllowAnonymous] [HttpPost] public ActionResult UpdateProducts(string ModelString){ } </code></pre> <p>And below is the string which i am getting in action(in ModelString variable):-</p> <pre><code>[{"name":"AddressNumber","value":"1"},{"name":"OrganizationProd","value":""},{"name":"ClientId","value":""},{"name":"ProductId","value":""},{"name":"TaxId1","value":""},{"name":"TaxId2","value":""},{"name":"LaborID","value":"0"}] </code></pre> <p>And after that i am deserializing the string like that :-</p> <pre><code>var sear = new JavaScriptSerializer(); var dictDynamic = sear.Deserialize&lt;dynamic&gt;(ModelString); </code></pre> <p>And i am getting the dynamic array in dictDynamic variable.And now i want to get the properties by its name not by indexing from dictDynamic object.</p> <p>Currently i am getting the properties by indexing like this :-</p> <pre><code>dictDynamic[0]["value"] dictDynamic[1]["value"] </code></pre> <p>But i want to parse it by properties name like this :-</p> <pre><code>dictDynamic["Name"]["value"] dictDynamic["Description"]["value"] </code></pre> <p>Can anyone help me out on this ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload