当前位置: 首页>>代码示例>>C#>>正文


C# JsonData.ToJson方法代码示例

本文整理汇总了C#中LitJson.JsonData.ToJson方法的典型用法代码示例。如果您正苦于以下问题:C# JsonData.ToJson方法的具体用法?C# JsonData.ToJson怎么用?C# JsonData.ToJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LitJson.JsonData的用法示例。


在下文中一共展示了JsonData.ToJson方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createResource

        public static void createResource()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            DirectoryInfo di = new DirectoryInfo(Global.PATH + "/res");
            var jd = new LitJson.JsonData();
            FileInfo[] fs = di.GetFiles("*", SearchOption.TopDirectoryOnly);

            foreach (FileInfo fi in fs)
            {
                if (fi.Name.Contains(".manifest"))
                {
                    continue;
                }

                string pPath = "res/" + fi.Name;
                jd[pPath.Replace("/", "@").Replace("\\", "@")] = pPath;
            }


            getJsonData(jd,"");
            JsonWriter writer = new JsonWriter(sb);
            writer.PrettyPrint = true;
            writer.IndentValue = 4;
            jd.ToJson(writer);
             
            

 
            string result = CoccosHelper.Properties.Resources.tpl.Replace("#1#", sb.ToString());
            File.WriteAllText(Global.PATH + "/src/resource.js", result);

        }
开发者ID:wshxbqq,项目名称:Cocos2dxJs-Helper,代码行数:32,代码来源:Resource.cs

示例2: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            if (context.Session["SlipAdmin"] == null)
            {
                //保存出错

                context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                context.Response.StatusCode = 401;
                context.Response.StatusDescription = "您没有登录或登录超时,请重新登录!";
                context.Response.End();
            }
            int status = 0;
            string msg = "未知错误";
            DataModal dm = new DataModal();
            try
            {
                int ef =dm.DeleteNews(context.Request.Params["nids"]);
                status = 1;
                msg = "成功删除" + ef + "条记录";

            }
            catch (Exception ex)
            {
                status = 2;
                msg = ex.Message;
            }

            JsonData jd = new JsonData();
            jd["status"] = status;
            jd["msg"] = msg;
            context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            context.Response.Write(jd.ToJson());
            context.Response.End();
        }
开发者ID:satanrabbit,项目名称:syglTest,代码行数:34,代码来源:ndl.ashx.cs

示例3: Post

		public IEnumerator Post (string url) {
			// HEADERはHashtableで記述
			Hashtable header = new Hashtable ();
			header.Add ("Content-Type", "application/json; charset=UTF-8");
			
			// LitJsonを使いJSONデータを生成
			JsonData obj = new JsonData();
			obj["itemName"] = "katana";
			obj["itemType"] = "buki";
			obj["price"] = 300;
			obj["attack"] = "10";
			obj["defense"] = "0";
			obj["description"] = "atk";
			
			// シリアライズする(LitJson.JsonData→JSONテキスト)
			string postJsonStr = obj.ToJson();
			Debug.Log(postJsonStr);
			byte[] postBytes = Encoding.Default.GetBytes (postJsonStr);
			
			// 送信開始
			WWW www = new WWW (url, postBytes, header);
			yield return www;
			
			// 成功
			if (ErrorCheck(www)) {
				Debug.Log("WWW Ok!: " + www.data);
			}
			// 失敗
			else{
				Debug.Log("WWW Error: "+ www.error);          
			}
		}
开发者ID:trananh1992,项目名称:3DActionGame,代码行数:32,代码来源:GetPostJsonController.cs

示例4: Marshal

 public string Marshal()
 {
     JsonData data = new JsonData();
     data["S"] = Pattern;
     data["E"] = Deadline;
     return data.ToJson();
 }
开发者ID:89sos98,项目名称:csharp-sdk,代码行数:7,代码来源:DownloadPolicy.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                int status = 0;
                string msg = "未知错误";
                int wkpID = Convert.ToInt32(Request.Params["wkpID"]);
                float wlpReal = float.Parse(Request.Params["wlpReal"]);
                int wlpAdmin = Convert.ToInt32(Session["adminID"].ToString());
                string wlpTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                LNSql lnSql = new LNSql();
                lnSql.conn.Open();
                try
                {
                    lnSql.cmd.CommandText = "update wkPay_tb set [email protected] , [email protected],[email protected] where wkpID=" + wkpID;
                    lnSql.cmd.Parameters.AddWithValue("@wlpReal", wlpReal);
                    lnSql.cmd.Parameters.AddWithValue("@wlpAdmin", wlpAdmin);
                    lnSql.cmd.Parameters.AddWithValue("@wlpTime", wlpTime);
                    lnSql.cmd.Parameters.AddWithValue("@wkpID", wkpID);
                    lnSql.cmd.ExecuteNonQuery();
                    status = 1;
                    msg = "保存成功!";
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                }
                finally
                {
                    lnSql.conn.Close();
                    JsonData jsonData = new JsonData();
                    jsonData["status"] = status;
                    jsonData["msg"] = msg;
                    string echoString = jsonData.ToJson();

                    Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                    Response.Write(echoString);
                    Response.End();
                }

            }
            else
            {
                int wkpID = Convert.ToInt32(Request.Params["did"]);
                LNSql lnSql = new LNSql();
                lnSql.conn.Open();
                lnSql.cmd.CommandText = "select wlpReal from wkPay_tb where wkpID=" + wkpID;
                lnSql.dr = lnSql.cmd.ExecuteReader();
                if (lnSql.dr.Read())
                {
                    if (lnSql.dr["wlpReal"] != null)
                    {
                        this.wlpReal.Text = lnSql.dr["wlpReal"].ToString();
                    }
                }

                lnSql.conn.Close();
                this.wkpID.Value = wkpID.ToString();
            }
        }
开发者ID:satanrabbit,项目名称:LinaCWS,代码行数:60,代码来源:pay.aspx.cs

示例6: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if ( Session["SlipAdmin"] == null)
            {
                //保存出错

                Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                Response.StatusCode = 402;
                Response.StatusDescription = "您没有登录或登录超时,请重新登录!";
                Response.End();
            }
            if (IsPostBack)
            {
                JsonData jd = new JsonData();

                int status = 0;
                string msg = "未知状态";
                Support spt = new Support();
                DataModal dm = new DataModal();
                try
                {
                    spt.supportID = Convert.ToInt32(Request.Form["supportID"]);
                    spt.supportTitle = Request.Form["supportTitle"];
                    spt.supportContent = Request.Form["supportContent"];
                    dm.SaveSupport(spt);
                    status = 1;
                    msg = "保存成功!";
                }
                catch (Exception ex)
                {
                    msg = "错误:" + ex.Message;
                }

                jd["stauts"] = status;
                jd["msg"] = msg;
                Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                Response.Write(jd.ToJson());
                Response.End();
            }
            else
            {
                int id = 1;
                if (Request.Params["id"] == null || Request.Params["id"] == "")
                {
                    id = 1;
                }
                else
                {
                    id = Convert.ToInt32(Request.Params["id"]);
                }

                Support spt = new Support();
                DataModal dm = new DataModal();
                spt = dm.GetSupport(id);
                this.supportContent.Text = spt.supportContent;
               this.supportID.Value = spt.supportID.ToString();
               this.supportTitle.Text = spt.supportTitle;
               this.supportTitle.ReadOnly = true;
            }
        }
开发者ID:satanrabbit,项目名称:syglTest,代码行数:60,代码来源:espt.aspx.cs

示例7: Deserialize

 public void Deserialize(string json)
 {
     data = JsonMapper.ToObject(json);
     IShip ww = JsonMapper.ToObject<VikingShip>(data.ToJson());
    
 
 }
开发者ID:VitaliyXV,项目名称:AllegroTest,代码行数:7,代码来源:BaseSerializer.cs

示例8: button1_Click

 private void button1_Click(object sender, EventArgs e)
 {
     JsonData pjd = new JsonData();
     pjd["OPCODE"] = (Int32)GameOpcode.CreateSprite;
     pjd["UUID"] = game.SelfUUID;
     Program.SendDataSingle(pjd.ToJson(), game.SelfUUID);
 }
开发者ID:nodephp,项目名称:GrapesGameEngineWeb,代码行数:7,代码来源:Form1.cs

示例9: pack2Get

 public static WWW pack2Get(string path, JsonData jsdata)
 {
     if (!string.IsNullOrEmpty(accessToken) && !jsdata.Keys.Contains(TokenIDKey))
         jsdata[TokenIDKey] = accessToken;
     string str = jsdata.ToJson ();
     int cid = jsdata.Keys.Contains ("cmdid") ? int.Parse (jsdata ["cmdid"].ToString ()) : -1;
     return pack2Get(path, str, true,cid);
 }
开发者ID:JimmyHuang83,项目名称:GameEngine,代码行数:8,代码来源:NetUtils.cs

示例10: GenerateSkillAppendData

        public override string GenerateSkillAppendData()
        {
            JsonData json = new JsonData();
            json["lastRound"] = this.lastRound;
            json["allLastRound"] = this.allLastRound;

            return json.ToJson();
        }
开发者ID:weimingtom,项目名称:ACGCard-Server,代码行数:8,代码来源:StateSkill.cs

示例11: ButtonClick

 //计算按钮的点击事件
 void ButtonClick(GameObject button)
 {
     JsonData data = new JsonData ();
     data ["name"] = username.text;
     data ["password"] = password.text;
     byte[] msg = System.Text.UTF8Encoding.UTF8.GetBytes (data.ToJson ());
     NetMgr.Instance.SendMsg (msg, 1);
 }
开发者ID:standardprogram,项目名称:GameDoc,代码行数:9,代码来源:LoginUI.cs

示例12: GenerateSkillAppendData

        public override string GenerateSkillAppendData()
        {
            JsonData data = new JsonData();
            data["damage"] = GetCalculatedDamage();
            data["energy"] = this.skillEnergyCost;

            return data.ToJson();
        }
开发者ID:weimingtom,项目名称:ACGCard-Server,代码行数:8,代码来源:AttackSkill.cs

示例13: GenerateEquipAppend

        protected PlayerCard EquipedCard; //装备了该装备的英雄

        #endregion Fields

        #region Methods

        public string GenerateEquipAppend()
        {
            JsonData json = new JsonData();

            //----这里实现装备附加值的添加

            return json.ToJson();
        }
开发者ID:weimingtom,项目名称:ACGCard-Server,代码行数:14,代码来源:EquipmentCard.cs

示例14: returnMsg

 public void returnMsg(int status,string msg)
 {
     JsonData jd = new JsonData();
     jd["stauts"] = status;
     jd["msg"] = msg;
     Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
     Response.Write(jd.ToJson());
     Response.End();
 }
开发者ID:satanrabbit,项目名称:syglTest,代码行数:9,代码来源:en.aspx.cs

示例15: IntArrayToString

    public static string IntArrayToString(int[] array)
    {
        JsonData data = new JsonData();
        foreach (int a in array)
        {
            data.Add(a);
        }

        return data.ToJson();
    }
开发者ID:zhutaorun,项目名称:ACGCard-for-Unity3D,代码行数:10,代码来源:IntArray.cs


注:本文中的LitJson.JsonData.ToJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。