title: How can I return a Dictionary<string, Object> as JsonResult, AND get the proper result in JavaScript?
body: <p>I'm constructing my JsonResult in Controller by adding some extra information to an already existing JsonResult (returned from a different method). In order to add more properties, I converted the initial JsonResult into a Dictionary:</p>
  
  <pre><code>IDictionary&lt;string, object&gt; wrapper = (IDictionary&lt;string, object&gt;)new 
       System.Web.Routing.RouteValueDictionary(json.Data);
  </code></pre>
  
  <p>Then I just add data by writing <code>wrapper["..."] = "value"</code>.</p>
  
  <p>The method returns a new JsonResult, with wrapper as .Data:</p>
  
  <pre><code>new JsonResult() { wrapper, JsonRequestBehavior.AllowGet };
  </code></pre>
  
  <p>and that's where the troubles start; while communication happens perfectly, and the success function gets called, the resulting array which I use in JavaScript doesn't have the clean structure I expect: instead of accessing values as <code>val = ret.PropName1;</code> I end up having to access a simple indexed array, which contains in turn a dictionary with two pairs: <code>{ "Value"="val, "Key"="PropName1" };</code> (so something like <code>o[0].Key</code> would give me the property name)</p>
  
  <p>I'd like to know if there's a smart, fast way to rewrite the JsonResult creation in the Controller, to get a nice clean dictionary in the View.
  There are a couple of ideas I have, but they aren't particularly clean: I could throw away JsonResult reuse on the server side, and just make an anonymous object with all the right properties; or, I could make a translation function in Javascript which could translate the result into a new Array(). I'm looking for better solutions.</p>
  
  <p><strong>[Later Edit]</strong> The array comes the way it does because the dictionary was defined as <code>&lt;string, object&gt;</code>. If it were <code>&lt;string, string&gt;</code>, it would be sent the way I'd originally expect it. But since I actually use objects from that bag, I'll just leave it the way it is, and pass the json response through the below function.</p>