本文整理汇总了C#中JsonObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.ToString方法的具体用法?C# JsonObject.ToString怎么用?C# JsonObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDepthNode
private void GetDepthNode(HttpContext context)
{
DataSet list;
int regionId = Globals.SafeInt(context.Request.Params["NodeId"], 0);
JsonObject obj2 = new JsonObject();
if (regionId > 0)
{
Maticsoft.Model.Ms.Regions model = this.RegionBll.GetModel(regionId);
list = this.RegionBll.GetList("Depth=" + model.Depth);
}
else
{
list = this.RegionBll.GetList("Depth=1");
}
if (list.Tables[0].Rows.Count < 1)
{
obj2.Accumulate("STATUS", "NODATA");
context.Response.Write(obj2.ToString());
}
else
{
obj2.Accumulate("STATUS", "OK");
obj2.Accumulate("DATA", list.Tables[0]);
context.Response.Write(obj2.ToString());
}
}
示例2: AddRuleProduct
private string AddRuleProduct(HttpContext context)
{
JsonObject obj2 = new JsonObject();
int num = Convert.ToInt32(context.Request.Form["ProductId"]);
int ruleId = Convert.ToInt32(context.Request.Form["RuleId"]);
string str = context.Request.Form["ProductName"];
if (this.ruleProductBll.Exists(ruleId, (long) num))
{
obj2.Put("STATUS", "Presence");
return obj2.ToString();
}
Maticsoft.Model.Shop.Sales.SalesRuleProduct model = new Maticsoft.Model.Shop.Sales.SalesRuleProduct {
ProductId = num,
RuleId = ruleId,
ProductName = str
};
if (this.ruleProductBll.Add(model))
{
obj2.Put("STATUS", "SUCCESS");
obj2.Put("DATA", "Approve");
return obj2.ToString();
}
obj2.Put("STATUS", "NODATA");
return obj2.ToString();
}
示例3: GetDepartmentMapById
protected virtual void GetDepartmentMapById(HttpContext context)
{
JsonObject obj2 = new JsonObject();
int departmentId = Globals.SafeInt(context.Request.Params["DepartmentId"], 0);
if (departmentId < 1)
{
obj2.Accumulate("ERROR", "NOENTERPRISEID");
context.Response.Write(obj2.ToString());
}
else
{
MapInfo modelByDepartmentId = this.mapInfoManage.GetModelByDepartmentId(departmentId);
if (modelByDepartmentId == null)
{
obj2.Accumulate("STATUS", "NODATA");
context.Response.Write(obj2.ToString());
}
else
{
obj2.Accumulate("STATUS", "OK");
obj2.Accumulate("DATA", modelByDepartmentId);
context.Response.Write(obj2.ToString());
}
}
}
示例4: ProcessRequest
public override void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string str = context.Request.Form["Action"];
context.Response.Clear();
context.Response.ContentType = "application/json";
try
{
string str2 = str;
if (str2 != null)
{
if (!(str2 == "GetSKUByProductId"))
{
if (str2 == "MaxSequence")
{
goto Label_006B;
}
}
else
{
this.GetSKUByProductId(context);
}
}
return;
Label_006B:
this.GetMaxSequence(context);
}
catch (Exception exception)
{
JsonObject obj2 = new JsonObject();
obj2.Put("STATUS", "ERROR");
obj2.Put("DATA", exception);
context.Response.Write(obj2.ToString());
}
}
示例5: AutoProduct
public ActionResult AutoProduct(string productName)
{
ProductProvider provider = new ProductProvider();
List<ProductEntity> list = provider.GetListByCache();
if (!list.IsNullOrEmpty() && !productName.IsEmpty())
{
list = list.Where(a => a.ProductName.Contains(productName) || a.BarCode.Contains(productName) || a.SnNum.Contains(productName)).ToList();
}
list = list.IsNull() ? new List<ProductEntity>() : list;
StringBuilder sb = new StringBuilder();
JsonObject jsonObject = null;
foreach (ProductEntity t in list)
{
jsonObject = new JsonObject();
jsonObject.AddProperty("BarCode", t.BarCode);
jsonObject.AddProperty("ProductName", t.ProductName);
jsonObject.AddProperty("SnNum", t.SnNum);
jsonObject.AddProperty("CateNum", t.CateNum);
jsonObject.AddProperty("CateName", t.CateName);
jsonObject.AddProperty("InPrice", t.InPrice);
jsonObject.AddProperty("Unit", t.UnitNum);
jsonObject.AddProperty("UnitName", t.UnitName);
jsonObject.AddProperty("Size", t.Size);
jsonObject.AddProperty("Num", t.Num);
sb.Append(jsonObject.ToString() + "\n");
}
if (sb.Length == 0)
{
sb.Append("\n");
}
return Content(sb.ToString());
}
示例6: encode
/// <summary>
/// Encode the messge with id, route and jsonObject.
/// </summary>
/// <param name='id'>
/// Identifier.
/// </param>
/// <param name='route'>
/// Route.
/// </param>
/// <param name='jsonObject'>
/// Json object.
/// </param>
/// <exception cref='System.ArgumentException'>
/// Is thrown when the argument exception.
/// </exception>
public static string encode(int id, string route, JsonObject jsonObject)
{
if (route.Length > 255) {
throw new System.ArgumentException("route maxlength is overflow");
}
byte[] byteArray = new byte[HEADER + route.Length];
int index = 0;
byteArray[index++] = Convert.ToByte((id >> 24) & 0xFF);
byteArray[index++] = Convert.ToByte((id >> 16) & 0xFF);
byteArray[index++] = Convert.ToByte((id >> 8) & 0xFF);
byteArray[index++] = Convert.ToByte(id & 0xFF);
byteArray[index++] = Convert.ToByte(route.Length & 0xFF);
char[] routeArray = route.ToCharArray();
int routeLength = routeArray.Length;
for(int i = 0; i < routeLength; i++) {
byteArray[index++] = Convert.ToByte(routeArray[i]);
}
string encodeString = "";
try{
encodeString = Encoding.UTF8.GetString(byteArray);
}catch(Exception e){
Console.WriteLine(string.Format("Error in new Encoding.UTF8.GetString:{0}", e.Message));
}
return encodeString + jsonObject.ToString();
}
示例7: ProcessRequest
public override void ProcessRequest(HttpContext context)
{
string str = context.Request.Form["Action"];
context.Response.Clear();
context.Response.ContentType = "application/json";
try
{
string str2 = str;
if (str2 != null)
{
if (!(str2 == "EditRecomend"))
{
if (str2 == "EditStatus")
{
goto Label_005B;
}
}
else
{
this.EditRecomend(context);
}
}
return;
Label_005B:
this.EditStatus(context);
}
catch (Exception exception)
{
JsonObject obj2 = new JsonObject();
obj2.Put("STATUS", "ERROR");
obj2.Put("DATA", exception);
context.Response.Write(obj2.ToString());
}
}
示例8: UserPoll
private string UserPoll(HttpContext context)
{
JsonObject obj2 = new JsonObject();
int num = Convert.ToInt32(context.Request.Form["UID"]);
string str = context.Request.Form["Option"];
string str2 = context.Request.Form["FID"];
if (context.Request.Cookies["vote" + str2] != null)
{
HttpCookie cookie = context.Request.Cookies["vote" + str2];
if ((cookie.Values["voteid"].ToString() != "") || (cookie.Values["voteid"].ToString() != null))
{
obj2.Put("STATUS", "FAILED");
}
}
Maticsoft.BLL.Poll.UserPoll poll = new Maticsoft.BLL.Poll.UserPoll();
string[] strArray = str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
Maticsoft.Model.Poll.UserPoll model = null;
for (int i = 0; i < strArray.Length; i++)
{
string[] strArray2 = strArray[i].Split(new char[0x5f], StringSplitOptions.RemoveEmptyEntries);
model.CreatTime = new DateTime?(DateTime.Now);
model.TopicID = new int?(int.Parse(strArray2[0]));
model.UserID = num;
model.UserIP = context.Request.UserHostAddress;
model.OptionID = new int?(int.Parse(strArray2[1]));
poll.Add(model);
}
obj2.Put("STATUS", "SUCCESS");
return obj2.ToString();
}
示例9: Main
public static void Main()
{
// Create a request using a URL that can receive a post.
WebRequest request = WebRequest.Create ("http://api.chronojump.org:8080/ping");
// Set the Method property of the request to POST.
request.Method = "POST";
// Set the ContentType property of the WebRequest.
request.ContentType = "application/json";
// Creates the json object
JsonObject json = new JsonObject();
json.Add("os_version", "Linux");
json.Add("cj_version", "0.99");
// Converts it to a String
String js = json.ToString();
// Writes the json object into the request dataStream
Stream dataStream = request.GetRequestStream ();
dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
dataStream.Close ();
// Get the response.
WebResponse response = request.GetResponse ();
// Display the status (will be 201, CREATED)
Console.WriteLine (((HttpWebResponse)response).StatusDescription);
// Clean up the streams.
dataStream.Close ();
response.Close ();
}
示例10: GetCategoryInfo
public void GetCategoryInfo(HttpContext context)
{
Func<Maticsoft.Model.SNS.Categories, bool> predicate = null;
string categoryId = context.Request.Params["CID"];
int type = Globals.SafeInt(context.Request.Params["Type"], 0);
JsonObject obj2 = new JsonObject();
if (!string.IsNullOrWhiteSpace(categoryId))
{
if (predicate == null)
{
predicate = c => c.ParentID == Globals.SafeInt(categoryId, 0);
}
List<Maticsoft.Model.SNS.Categories> list2 = this.SNSCateBll.GetAllCateByCache(type).Where<Maticsoft.Model.SNS.Categories>(predicate).ToList<Maticsoft.Model.SNS.Categories>();
if ((list2 != null) && (list2.Count > 0))
{
JsonArray data = new JsonArray();
list2.ForEach(delegate (Maticsoft.Model.SNS.Categories info) {
data.Add(new JsonObject(new string[] { "CategoryId", "Name", "ParentID", "HasChildren" }, new object[] { info.CategoryId, info.Name, info.ParentID, info.HasChildren }));
});
obj2.Put("STATUS", "Success");
obj2.Put("DATA", data);
}
else
{
obj2.Put("STATUS", "Fail");
}
}
else
{
obj2.Put("STATUS", "Error");
}
context.Response.Write(obj2.ToString());
}
示例11: AddAttention
public void AddAttention(FormCollection collection)
{
if (!base.HttpContext.User.Identity.IsAuthenticated || (base.CurrentUser == null))
{
base.RedirectToAction("Login");
}
else
{
JsonObject obj2 = new JsonObject();
string str = collection["PassiveUserID"];
if (!string.IsNullOrWhiteSpace(str))
{
if (PageValidate.IsNumberSign(str) && this.bllUserShip.AddAttention(base.CurrentUser.UserID, int.Parse(str)))
{
obj2.Accumulate("STATUS", "SUCC");
}
else
{
obj2.Accumulate("STATUS", "FAIL");
}
}
else
{
obj2.Accumulate("STATUS", "FAIL");
}
base.Response.Write(obj2.ToString());
}
}
示例12: SerializeItemReferences
public byte[] SerializeItemReferences(IList<Models.InventoryItemReferenceSaveLookup> toSerialize)
{
var jsonArr = new JsonObject();
jsonArr.Add("data", toSerialize);
return Encoding.UTF8.GetBytes(jsonArr.ToString());
}
示例13: ProcessSub
protected override void ProcessSub(HttpContext context, string uploadPath, string fileName)
{
JsonObject obj2 = new JsonObject();
obj2.Put("data", uploadPath + "T_" + fileName);
obj2.Put("success", true);
context.Response.Write(obj2.ToString());
}
示例14: GenerateHtml
protected void GenerateHtml(HttpContext context)
{
JsonObject obj2 = new JsonObject();
string valueByCache = ConfigSystem.GetValueByCache("MainArea");
int TaskId = Globals.SafeInt(context.Request.Form["TaskId"], 0);
Maticsoft.Model.SysManage.TaskQueue model = TaskList.FirstOrDefault<Maticsoft.Model.SysManage.TaskQueue>(c => c.ID == TaskId);
if (model != null)
{
string str2 = "";
string str3 = PageSetting.GetCMSUrl(model.TaskId, "CMS", ApplicationKeyType.CMS);
if (valueByCache == "CMS")
{
str2 = "/Article/Details/" + model.TaskId;
}
else
{
str2 = "/CMS/Article/Details/" + model.TaskId;
}
if (!string.IsNullOrWhiteSpace(str2) && !string.IsNullOrWhiteSpace(str3))
{
if (Maticsoft.BLL.CMS.GenerateHtml.HttpToStatic(str2, str3))
{
model.RunDate = new DateTime?(DateTime.Now);
model.Status = 1;
this.taskBll.Update(model);
obj2.Put("STATUS", "SUCCESS");
}
else
{
obj2.Put("STATUS", "FAILED");
}
}
context.Response.Write(obj2.ToString());
}
}
示例15: SetDepartmentMap
protected void SetDepartmentMap(HttpContext context)
{
JsonObject obj2 = new JsonObject();
User user = context.Session[Globals.SESSIONKEY_ENTERPRISE] as User;
if (user != null)
{
int num = Globals.SafeInt(context.Request.Params["DepartmentId"], 0);
string str = context.Request.Params["MarkersLongitude"];
string str2 = context.Request.Params["MarkersDimension"];
string target = context.Request.Params["PointerTitle"];
string content = context.Request.Params["PointerContent"];
string str5 = context.Request.Params["PointImg"];
int num2 = Globals.SafeInt(context.Request.Params["MapId"], 0);
if (num < 1)
{
obj2.Accumulate("ERROR", "NOENTERPRISEID");
context.Response.Write(obj2.ToString());
}
else
{
MapInfo model = new MapInfo {
UserId = user.UserID,
DepartmentId = num,
MarkersLongitude = str,
MarkersDimension = str2,
PointerTitle = Globals.HtmlEncode(target),
PointerContent = Globals.HtmlEncodeForSpaceWrap(content)
};
if (!string.IsNullOrWhiteSpace(str5))
{
model.PointImg = str5;
}
if (num2 < 1)
{
model.MapId = base.mapInfoManage.Add(model);
}
else
{
model.MapId = num2;
base.mapInfoManage.Update(model);
}
obj2.Accumulate("STATUS", "OK");
obj2.Accumulate("DATA", model);
context.Response.Write(obj2.ToString());
}
}
}