var obj = new JObject { {"Head", new JObject { { "key","" }, { "key",transCode }, { "key", transId }, { "key", "" } } }, {"Body", new JObject { { "CreateDateTime", _datetime.Now.DateTime } } } }; result = new ContentResult() { Content = Newtonsoft.Json.JsonConvert.SerializeObject(obj), ContentType = "application/json" };
XDocument obj = new XDocument(new XDeclaration("1.0", "utf-8", "yes")); XElement root = new XElement("response", new XElement("key", "success"), new XElement("key", ""), new XElement("key", "")); obj.Add(root); result = new ContentResult() { Content = obj.ToString(), ContentType = "application/xml" };