本文整理汇总了C#中JsonFx.Json.JsonReader类的典型用法代码示例。如果您正苦于以下问题:C# JsonReader类的具体用法?C# JsonReader怎么用?C# JsonReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonReader类属于JsonFx.Json命名空间,在下文中一共展示了JsonReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JobList
private List<string> JobList()
{
List<string> Jobs = new List<string>();
string URL = Deployinator.Config.JenkinsUrl + "/api/json";
Log.Info("requesting " + URL);
HttpWebRequest Req = (HttpWebRequest)WebRequest.Create(URL);
HttpWebResponse Resp = (HttpWebResponse)Req.GetResponse();
if ( Resp.StatusCode == System.Net.HttpStatusCode.OK)
{
System.IO.Stream ResponseStream = Resp.GetResponseStream();
System.IO.StreamReader StreamReader = new System.IO.StreamReader(ResponseStream);
JsonReader Reader = new JsonReader();
String Json = StreamReader.ReadToEnd();
Dictionary<string, Object> JsonDict = Reader.Read<Dictionary<string, Object>>(Json);
Dictionary<string, Object>[] JsonJobs = (Dictionary<string, Object>[]) JsonDict["jobs"];
for ( int i = 0 ; i < JsonJobs.Length ; i++ )
{
Dictionary<string, Object> JsonJob = (Dictionary<string, Object>) JsonJobs[i];
Jobs.Add((string)JsonJob["name"]);
}
}
else
{
Log.Info("returned non 200 " + Resp.StatusCode.ToString());
}
return Jobs;
}
示例2: ExtractAppRevenueData
public List<dynamic> ExtractAppRevenueData(string appName, string queryString)
{
var revenueData = DistimoService.GetDistimoData(SupportedDistimoApis.Revenues, queryString);
var reader = new JsonReader();
dynamic output = reader.Read(revenueData);
List<dynamic> filteredList = new List<dynamic>();
try
{
foreach (dynamic line in output.lines)
{
string localAppName = line.data.application;
if (localAppName.Contains(appName))
filteredList.Add(line);
}
}
catch (RuntimeBinderException)
{
// too many requests, try again
Thread.Sleep(1100);
return ExtractAppRevenueData(appName, queryString);
}
return filteredList;
}
示例3: handleMessage
public void handleMessage(Message msg)
{
if (msg is CardTypesMessage)
{
JsonReader jsonReader = new JsonReader();
Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["cardTypes"];
this.cardids = new int[d.GetLength(0)];
this.cardnames = new string[d.GetLength(0)];
this.cardImageid = new int[d.GetLength(0)];
for (int i = 0; i < d.GetLength(0); i++)
{
cardids[i] = Convert.ToInt32(d[i]["id"]);
cardnames[i] = d[i]["name"].ToString();
cardImageid[i] = Convert.ToInt32(d[i]["cardImage"]);
}
App.Communicator.removeListener(this);//dont need the listener anymore
}
return;
}
示例4: onReqChangeSuccess
private void onReqChangeSuccess(BaseWWWRequest obj)
{
try
{
ChangeEquipData data = new JsonFx.Json.JsonReader().Read<ChangeEquipData>(this.UTF8String);
base.responseData = data;
if (data.eid != 0)
{
this.onReqChangeFail(obj);
}
else
{
if (data.shipVO != null)
{
GameData.instance.UpdateUserShip(data.shipVO);
}
if (data.detailInfo != null)
{
GameData.instance.UserInfo.UpdateDetailInfo(data.detailInfo);
}
this.UpdateEquip();
this.OnChangeEquipSuccess(EventArgs.Empty);
}
}
catch (Exception exception)
{
z.log(exception.Message);
this.onReqChangeFail(obj);
}
}
示例5: LoadData
public void LoadData()
{
// Make sure it's time to update
if( DateTime.Compare(nextUpdate, DateTime.UtcNow) == 1 ) {
return;
}
nextUpdate = DateTime.UtcNow.AddHours(1);
// Grab new data
WebClient wc = new WebClient();
try {
wc.QueryString.Add("formatting", "1");
String period = (String) mod.config.GetWithDefault("data-period", "1-day");
String result = wc.DownloadString(new Uri("http://api.scrollspost.com/v1/prices/" + period));
// Load it up
List<APIPriceCheckResult> prices = new JsonReader().Read<List<APIPriceCheckResult>>(result);
foreach( APIPriceCheckResult scroll in prices ) {
scrolls[scroll.card_id] = scroll;
}
} catch ( WebException we ) { // eeeeeeeeeeeeeeee
App.Popups.ShowOk(this, "fail", "HTTP Error", "Unable to load pricing data, contact [email protected] for help.\n\n" + we.Message, "Ok");
mod.WriteLog("Failed to load pricing data", we);
}
}
示例6: onReqChangeSuccess
private void onReqChangeSuccess(BaseWWWRequest obj)
{
try
{
DestroyShipData data = new JsonFx.Json.JsonReader().Read<DestroyShipData>(this.UTF8String);
base.responseData = data;
if (data.eid != 0)
{
this.onReqChangeFail(obj);
}
else
{
if (data.userVo != null)
{
GameData.instance.UserInfo.UpdateResource(data.userVo);
}
if (data.equipmentVo != null)
{
GameData.instance.SetUserEquipments(data.equipmentVo);
}
if (data.detailInfo != null)
{
GameData.instance.UserInfo.UpdateDetailInfo(data.detailInfo);
}
this.UpdateShips();
this.OnDestroySuccess(EventArgs.Empty);
}
}
catch (Exception exception)
{
z.log(exception.Message);
this.onReqChangeFail(obj);
}
}
示例7: Convert
public object Convert(int operation, string packet)
{
object _packet = null;
UserOperation userOperation = (UserOperation)operation;
JsonReader jsonReader = new JsonReader(packet);
switch(userOperation)
{
case UserOperation.LOGIN:
_packet = jsonReader.Deserialize<LoginReply>();
break;
case UserOperation.REGISTER:
_packet = jsonReader.Deserialize<RegisterReply>();
break;
case UserOperation.CHARSELECT:
case UserOperation.CREATECHAR:
case UserOperation.DELETECHAR:
case UserOperation.SELECTCHAR:
_packet = jsonReader.Deserialize<CharSelectPacket>();
break;
default:
break;
}
return _packet;
}
示例8: Convert
public object Convert(int operation, string packet)
{
object _packet = null;
CharacterOperation key = (CharacterOperation)operation;
JsonReaderSettings settings = new JsonReaderSettings();
settings.AddTypeConverter (new VectorConverter());
settings.AddTypeConverter (new QuaternionConverter());
JsonReader jsonReader = new JsonReader(packet, settings);
switch(key)
{
case CharacterOperation.GROUNDCLICK:
_packet = jsonReader.Deserialize<GroundClick>();
break;
case CharacterOperation.INSTANTIATE:
_packet = jsonReader.Deserialize<InstantiateChar>();
break;
case CharacterOperation.DESTROY:
_packet = jsonReader.Deserialize<DestroyChar>();
break;
default:
break;
}
return _packet;
}
示例9: CreateJob
public string CreateJob(string jsondata)
{
var newjob = new WorkerJob();
newjob.ID = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
var jr = new JsonReader(jsondata);
var jo = jr.Deserialize() as Dictionary<string, object>;
if (jo.ContainsKey("callback"))
newjob.CallbackUrl = jo["callback"].ToString();
if (jo.ContainsKey("jobtype"))
newjob.JobType = jo["jobtype"].ToString();
// parse args...
if (jo.ContainsKey("jobargs"))
Utilities.FillArgsFromJson(newjob.JobArgs, jo["jobargs"]);
newjob.MyUrl = "http://" + _worker.Config.Hostname + ":" + _worker.Config.Port;
Console.WriteLine("WorkerJobController: Created job #" + newjob.ID + " with callback url " + newjob.CallbackUrl);
m_jobs.Add(newjob);
return newjob.ID;
}
示例10: readJsonfromGoogle
public void readJsonfromGoogle(string txt)
{
JsonReader jsonReader = new JsonReader();
Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(txt);
dictionary = (Dictionary<string, object>)dictionary["feed"];
Dictionary<string, object>[] entrys = (Dictionary<string, object>[])dictionary["entry"];
for (int i = 0; i < entrys.GetLength(0); i++)
{
/*for (int j = 0; j < 4; j++)
{
dictionary = (Dictionary<string, object>)entrys[i]["gsx$r"+(j+1)];
Console.WriteLine((string)dictionary["$t"]);
}*/
dictionary = (Dictionary<string, object>)entrys[i]["gsx$r1"];
if (((string)dictionary["$t"]).ToLower() == "version")
{
dictionary = (Dictionary<string, object>)entrys[i]["gsx$r2"];
this.newestversion=(string)dictionary["$t"];
Console.WriteLine("version string recived");
}
}
}
示例11: JsonTcpCommunication
public JsonTcpCommunication(TcpClient socket)
: base(socket)
{
JsonResolverStrategy resolver = new JsonResolverStrategy();
_jsonIn = new JsonReader(new DataReaderSettings(resolver));
_jsonOut = new JsonWriter(new DataWriterSettings(new ConventionResolverStrategy(ConventionResolverStrategy.WordCasing.CamelCase)));
}
示例12: handleMessage
public void handleMessage(Message msg)
{
if (msg is RoomEnterMessage)
{
RoomEnterMessage rms = (RoomEnterMessage)msg;
this.nomssg.Add(rms.roomName);
}
if (msg is RoomInfoMessage)
{
Console.WriteLine("joinleave bearbeitet: " + msg.getRawText());
//"removed";
//"updated";
JsonReader jsonReader = new JsonReader();
Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
string roomname = (string)dictionary["roomName"];
if (msg.getRawText().Contains("removed"))
{
Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["removed"];
for (int i = 0; i < d.Length; i++)
{
string ltext = d[i]["name"] + " has left the room";
RoomChatMessageMessage leftmessage = new RoomChatMessageMessage(roomname, "<color=#777460>" + ltext + "</color>");
App.ChatUI.handleMessage(leftmessage);
App.ArenaChat.ChatRooms.ChatMessage(leftmessage);
}
}
if (msg.getRawText().Contains("updated") && this.nomssg.Contains(roomname))
{
nomssg.RemoveAll(item => item == roomname);
}
else
{
if (msg.getRawText().Contains("updated"))
{
Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["updated"];
for (int i = 0; i < d.Length; i++)
{
string ltext = d[i]["name"] + " has joined the room";
RoomChatMessageMessage leftmessage = new RoomChatMessageMessage(roomname, "<color=#777460>" + ltext + "</color>");
App.ChatUI.handleMessage(leftmessage);
App.ArenaChat.ChatRooms.ChatMessage(leftmessage);
}
}
}
}
return;
}
示例13: ExecuteDynamic
public static IRestResponse<dynamic> ExecuteDynamic(this IRestClient client, IRestRequest request)
{
var response = client.Execute<dynamic>(request);
dynamic content = new JsonReader().Read(response.Content);
response.Data = content;
return response;
}
示例14: LoadShipConfigs
private void LoadShipConfigs()
{
if (this.shipConfigs != null)
{
AllConfigs configs = new JsonFx.Json.JsonReader().Read<AllConfigs>(this.shipConfigs);
AllShipConfigs.instance.setShips(configs.shipCard);
ServerRequestManager.instance.OnLoadConfigsComplete();
}
}
示例15: GetDecoder
public IDecoder GetDecoder()
{
var jsonReader = new JsonReader(new DataReaderSettings(DefaultEncoderDecoderConfiguration.CombinedResolverStrategy()
, new TeamCityDateFilter()), new[] { "application/.*json", "text/.*json" });
var readers = new List<IDataReader> { jsonReader };
var dataReaderProvider = new RegExBasedDataReaderProvider(readers);
return new DefaultDecoder(dataReaderProvider);
}