title: Newtonsoft as jsonResult
body: <p>I have MVC controller method which should return json string.</p>
  
  <pre><code>public JsonResult myMethod()
  {
    ....
    return Json(new { success = true, data = myObject });
  }
  </code></pre>
  
  <p>It works. But column order of myObject is not the same as defined.
  (Json by definition returns unordered set of name/value pairs)</p>
  
  <p>So, I have used Newtonsoft and on my class I have defined sort order like:</p>
  
  <pre><code>public class myObject{
  
   [JsonProperty(Order = 0)]
   public int id { get; set; }
  
   [JsonProperty(Order = 1)]
   public string name { get; set; }
   }
  </code></pre>
  
  <p>And in MVC controller have to change method to return string instead of JsonResult (I don't know how to use newtonsoft to return jsonResult). And then I return string:</p>
  
  <pre><code>return "{ success = true, data = " + Newtonsoft.Json.JsonConvert.SerializeObject(myObject) + "}";
  </code></pre>
  
  <p>It works, string has correct column order, but ajax method doesn't recognize this string as json. So, what would be the best solution? How to return jsonResult from newtonsoft instead of json string?</p>