本文整理汇总了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);
}
示例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();
}
示例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);
}
}
示例4: Marshal
public string Marshal()
{
JsonData data = new JsonData();
data["S"] = Pattern;
data["E"] = Deadline;
return data.ToJson();
}
示例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();
}
}
示例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;
}
}
示例7: Deserialize
public void Deserialize(string json)
{
data = JsonMapper.ToObject(json);
IShip ww = JsonMapper.ToObject<VikingShip>(data.ToJson());
}
示例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);
}
示例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);
}
示例10: GenerateSkillAppendData
public override string GenerateSkillAppendData()
{
JsonData json = new JsonData();
json["lastRound"] = this.lastRound;
json["allLastRound"] = this.allLastRound;
return json.ToJson();
}
示例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);
}
示例12: GenerateSkillAppendData
public override string GenerateSkillAppendData()
{
JsonData data = new JsonData();
data["damage"] = GetCalculatedDamage();
data["energy"] = this.skillEnergyCost;
return data.ToJson();
}
示例13: GenerateEquipAppend
protected PlayerCard EquipedCard; //装备了该装备的英雄
#endregion Fields
#region Methods
public string GenerateEquipAppend()
{
JsonData json = new JsonData();
//----这里实现装备附加值的添加
return json.ToJson();
}
示例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();
}
示例15: IntArrayToString
public static string IntArrayToString(int[] array)
{
JsonData data = new JsonData();
foreach (int a in array)
{
data.Add(a);
}
return data.ToJson();
}