本文整理汇总了C#中LitJson.JsonData类的典型用法代码示例。如果您正苦于以下问题:C# JsonData类的具体用法?C# JsonData怎么用?C# JsonData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonData类属于LitJson命名空间,在下文中一共展示了JsonData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TooManyFollows
public TooManyFollows(JsonData warning)
{
var warn = warning.GetValue<JsonData>("warning");
Code = warn.GetValue<string>("code");
Message = warn.GetValue<string>("message");
UserID = warn.GetValue<ulong>("user_id");
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:7,代码来源:TooManyFollows.cs
示例2: 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
示例3: DeserializeJson
public static OSD DeserializeJson(JsonData json)
{
switch (json.GetJsonType())
{
case JsonType.Boolean:
return OSD.FromBoolean((bool)json);
case JsonType.Int:
return OSD.FromInteger((int)json);
case JsonType.Long:
return OSD.FromLong((long)json);
case JsonType.Double:
return OSD.FromReal((double)json);
case JsonType.String:
string str = (string)json;
if (String.IsNullOrEmpty(str))
return new OSD();
else
return OSD.FromString(str);
case JsonType.Array:
OSDArray array = new OSDArray(json.Count);
for (int i = 0; i < json.Count; i++)
array.Add(DeserializeJson(json[i]));
return array;
case JsonType.Object:
OSDMap map = new OSDMap(json.Count);
foreach (KeyValuePair<string, JsonData> kvp in json)
map.Add(kvp.Key, DeserializeJson(kvp.Value));
return map;
case JsonType.None:
default:
return new OSD();
}
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:33,代码来源:OSDJson.cs
示例4: Relationship
public Relationship(JsonData relJson)
{
if (relJson == null) return;
ScreenName = relJson.GetValue<string>("screen_name");
Name = relJson.GetValue<string>("name");
RetweetsWanted = relJson.GetValue<bool>("want_retweets");
AllReplies = relJson.GetValue<bool>("all_replies");
MarkedSpam = relJson.GetValue<bool>("marked_spam");
ID = relJson.GetValue<ulong>("id");
Blocking = relJson.GetValue<bool>("blocking");
NotificationsEnabled = relJson.GetValue<bool>("notifications_enabled");
CanDm = relJson.GetValue<bool>("can_dm");
Muting = relJson.GetValue<bool>("muting", false);
var connections = relJson.GetValue<JsonData>("connections");
if (connections != null)
Connections =
(from JsonData connection in connections
select connection.ToString())
.ToList();
else
Connections = new List<string>();
FollowedBy =
relJson.GetValue<bool>("followed_by") ||
Connections.Contains("followed_by");
Following =
relJson.GetValue<bool>("following") ||
Connections.Contains("following");
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:31,代码来源:Relationship.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: 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
示例7: AspectRatio
public AspectRatio(JsonData aspectRatio)
{
if (aspectRatio == null) return;
Width = (int) aspectRatio[WidthIndex];
Height = (int) aspectRatio[HeightIndex];
}
开发者ID:mlzharov,项目名称:LinqToTwitter,代码行数:7,代码来源:AspectRatio.cs
示例8: Stall
public Stall(JsonData stall)
{
var warning = stall.GetValue<JsonData>("user_withheld");
Code = warning.GetValue<string>("code");
Message = warning.GetValue<string>("message");
PercentFull = warning.GetValue<int>("percent_full");
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:7,代码来源:Stall.cs
示例9: ParseModInfo
/// <summary>
/// Parses the mod's information from Json, loading any required references, and returns its <see cref="ModInfo"/> object.
/// </summary>
/// <param name="j">Json Data to load the <see cref="ModInfo"/> from</param>
/// <param name="path">The path to the mod</param>
/// <returns>The <see cref="ModInfo"/> of the mod</returns>
public static ModInfo ParseModInfo(JsonData j, string path)
{
var refs = new List<IReference>();
if (j.Has("dllReferences"))
foreach (object s in j["dllReferences"])
refs.Add(new AssemblyReference(s.ToString(), path));
if (j.Has("modReferences"))
foreach (object s in j["modReferences"])
refs.Add(new ModReference(s.ToString()));
string internalName = j.GetOrExn<string>("internalName");
return new ModInfo(
path,
internalName,
j.GetOrDef("displayName", internalName),
j.GetOrDef("author", "<unspecified>"),
j.GetOrDef("version", "0.0.0.0"),
j.GetOrDef<string>("description"),
j.GetOrExn<string>("asmFileName"),
j.GetOrExn<string>("modDefTypeName"),
refs.ToArray()
);
}
开发者ID:TerrariaPrismTeam,项目名称:Prism,代码行数:31,代码来源:ModData.cs
示例10: ToJsonData
public JsonData ToJsonData()
{
JsonData jsonData = new JsonData();
jsonData["queryRankType"] = this.queryRankType;
jsonData["QUERY_RANK_TYPE_SCORE"] = this.queryRankScope;
return jsonData;
}
开发者ID:floatyears,项目名称:Decrypt,代码行数:7,代码来源:QueryRankInfo.cs
示例11: ConvertExcel
private void ConvertExcel(string fullPath,string fileName)
{
FileStream fs = File.Open(fullPath,FileMode.Open,FileAccess.Read);
IExcelDataReader dataReader = ExcelReaderFactory.CreateOpenXmlReader(fs);
DataSet ds = dataReader.AsDataSet();
int row = ds.Tables[0].Rows.Count;
JsonData jd_root = new JsonData();
jd_root["name"] = fileName.Substring(0,fileName.Length - 5);
for(int i = 2;i<row;i++)
{
JsonData sub_jd = new JsonData();
var obj = ds.Tables[0].Rows[i];
object[] arr_objs = obj.ItemArray;
for(int j = 0;j<arr_objs.Length;j++)
{
object value = arr_objs[j];
string key = ds.Tables[0].Rows[0][j].ToString();
string type = ds.Tables[0].Rows[1][j].ToString();
if(type == "int")
{
sub_jd[key] = Convert.ToInt32(value);
}else if(type == "string")
{
sub_jd[key] = Convert.ToString(value);
}
}
jd_root[ds.Tables[0].Rows[i][0].ToString()] = sub_jd;
}
WriteToJson(fileName, JsonMapper.ToJson(jd_root));
}
开发者ID:zhaoyabo,项目名称:GameBase,代码行数:32,代码来源:Form1.cs
示例12: Delete
public Delete(JsonData delete)
{
var del = delete.GetValue<JsonData>("delete");
var status = del.GetValue<JsonData>("status");
StatusID = status.GetValue<ulong>("id");
UserID = status.GetValue<ulong>("user_id");
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:7,代码来源:Delete.cs
示例13: Disconnect
public Disconnect(JsonData json)
{
var disconnect = json.GetValue<JsonData>("disconnect");
Code = disconnect.GetValue<int>("code");
StreamName = disconnect.GetValue<string>("stream_name");
Reason = disconnect.GetValue<string>("reason");
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:7,代码来源:Disconnect.cs
示例14: Friendship
public Friendship(JsonData friendJson)
{
if (friendJson == null) return;
TargetRelationship = new Relationship(friendJson.GetValue<JsonData>("target"));
SourceRelationship = new Relationship(friendJson.GetValue<JsonData>("source"));
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:7,代码来源:Friendship.cs
示例15: RelatedResults
public RelatedResults(JsonData resultsJson)
{
if (resultsJson == null) return;
ResultAnnotations = new Annotation(resultsJson.GetValue<JsonData>("annotations"));
Score = resultsJson.GetValue<double>("score");
Kind = resultsJson.GetValue<string>("kind");
JsonData value = resultsJson.GetValue<JsonData>("value");
ValueAnnotations = new Annotation(value.GetValue<JsonData>("annotations"));
Retweeted = value.GetValue<bool>("retweeted");
InReplyToScreenName = value.GetValue<string>("in_reply_to_screen_name");
var contributors = value.GetValue<JsonData>("contributors");
Contributors =
contributors == null ?
new List<Contributor>() :
(from JsonData contributor in contributors
select new Contributor(contributor))
.ToList();
Coordinates = new Coordinate(value.GetValue<JsonData>("coordinates"));
Place = new Place(value.GetValue<JsonData>("place"));
User = new User(value.GetValue<JsonData>("user"));
RetweetCount = value.GetValue<int>("retweet_count");
IDString = value.GetValue<string>("id_str");
InReplyToUserID = value.GetValue<ulong>("in_reply_to_user_id");
Favorited = value.GetValue<bool>("favorited");
InReplyToStatusIDString = value.GetValue<string>("in_reply_to_status_id_str");
InReplyToStatusID = value.GetValue<ulong>("in_reply_to_status_id");
Source = value.GetValue<string>("source");
CreatedAt = value.GetValue<string>("created_at").GetDate(DateTime.MaxValue);
InReplyToUserIDString = value.GetValue<string>("in_reply_to_user_id_str");
Truncated = value.GetValue<bool>("truncated");
Geo = new Geo(value.GetValue<JsonData>("geo"));
Text = value.GetValue<string>("text");
}
开发者ID:prog-moh,项目名称:LinqToTwitter,代码行数:34,代码来源:RelatedResults.cs
示例16: 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
示例17: DeserializeJson
public static OSD DeserializeJson(JsonData json)
{
switch (json.GetJsonType())
{
case JsonType.Boolean:
return OSD.FromBoolean((bool)json);
case JsonType.Int:
return OSD.FromInteger((int)json);
case JsonType.Long:
return OSD.FromLong((long)json);
case JsonType.Double:
return OSD.FromReal((double)json);
case JsonType.String:
string str = (string)json;
if (String.IsNullOrEmpty(str))
return new OSD();
else
return OSD.FromString(str);
case JsonType.Array:
OSDArray array = new OSDArray(json.Count);
for (int i = 0; i < json.Count; i++)
array.Add(DeserializeJson(json[i]));
return array;
case JsonType.Object:
OSDMap map = new OSDMap(json.Count);
IDictionaryEnumerator e = ((IOrderedDictionary)json).GetEnumerator();
while (e.MoveNext())
map.Add((string)e.Key, DeserializeJson((JsonData)e.Value));
return map;
case JsonType.None:
default:
return new OSD();
}
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:34,代码来源:OSDJson.cs
示例18: 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
示例19: Parse
public static EvYield Parse(JsonData j, string key = "ev_yield")
{
JsonData v = j[key];
if (v.GetJsonType() == JsonType.String)
{
string val = (string)v;
string[] split = val.Split(' ');
int amt;
if (split.Length > 1)
{
string cat = split[1];
for (int i = 2; i < split.Length; i++)
cat += " " + split[i];
if (Int32.TryParse(split[0], out amt))
return new EvYield(amt, cat);
else
return new EvYield(0, cat);
}
else if (split.Length > 0 && Int32.TryParse(split[0], out amt))
return new EvYield(amt, String.Empty);
else
return new EvYield( 0, String.Empty);
}
return new EvYield((int)v, String.Empty);
}
开发者ID:BourbonShi,项目名称:PokeApi.NET,代码行数:31,代码来源:EvYield.cs
示例20: 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
注:本文中的LitJson.JsonData类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论