返回Json和返回XML的Object格式⭐⭐⭐⭐⭐
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" };
人各有命,上天注定,有人天生为王,有人落草为寇。脚下的路,如果不是你自己的选择,那么旅程的终点在哪,也没人知道。你会走到哪,会遇到谁,都不一定。