本文整理汇总了C#中Fiddler.Session.GetResponseAsJson方法的典型用法代码示例。如果您正苦于以下问题:C# Session.GetResponseAsJson方法的具体用法?C# Session.GetResponseAsJson怎么用?C# Session.GetResponseAsJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fiddler.Session
的用法示例。
在下文中一共展示了Session.GetResponseAsJson方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
private static kcsapi_ranking_getlist Serialize(Session session)
{
try
{
var djson = DynamicJson.Parse(session.GetResponseAsJson());
var rankings = new kcsapi_ranking_getlist
{
api_count = Convert.ToInt32(djson.api_data.api_count),
api_disp_page = Convert.ToInt32(djson.api_data.api_disp_page),
api_page_count = Convert.ToInt32(djson.api_data.api_page_count),
};
var list = new List<kcsapi_ranking>();
var serializer = new DataContractJsonSerializer(typeof(kcsapi_ranking));
foreach (var x in (object[])djson.api_data.api_list)
{
try
{
list.Add(serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(x.ToString()))) as kcsapi_ranking);
}
catch (SerializationException ex)
{
Debug.WriteLine(ex.Message);
}
}
rankings.api_list = list.ToArray();
return rankings;
}
catch (Exception ex)
{
Debug.WriteLine(ex);
return null;
}
}
示例2: Serialize
private static kcsapi_questlist Serialize(Session session)
{
try
{
var djson = DynamicJson.Parse(session.GetResponseAsJson());
var questlist = new kcsapi_questlist
{
api_count = Convert.ToInt32(djson.api_data.api_count),
api_disp_page = Convert.ToInt32(djson.api_data.api_disp_page),
api_page_count = Convert.ToInt32(djson.api_data.api_page_count),
api_exec_count = Convert.ToInt32(djson.api_data.api_exec_count),
};
var list = new List<kcsapi_quest>();
var serializer = new DataContractJsonSerializer(typeof(kcsapi_quest));
foreach (var x in (object[])djson.api_data.api_list)
{
try
{
list.Add(serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(x.ToString()))) as kcsapi_quest);
}
catch (SerializationException ex)
{
// 最後のページで任務数が 5 に満たないとき、api_list が -1 で埋められるというクソ API のせい
Debug.WriteLine(ex.Message);
}
}
questlist.api_list = list.ToArray();
return questlist;
}
catch (Exception ex)
{
Debug.WriteLine(ex);
return null;
}
}