本文整理汇总了C#中Jayrock.Json.JsonObject类的典型用法代码示例。如果您正苦于以下问题:C# JsonObject类的具体用法?C# JsonObject怎么用?C# JsonObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonObject类属于Jayrock.Json命名空间,在下文中一共展示了JsonObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRequest
public void ProcessRequest(HttpContext context)
{
string action = context.Request.Form["Action"];
context.Response.Clear();
context.Response.ContentType = "application/json";
try
{
switch (action)
{
#region 本月账单
case "currentMon":
TradeLsit(context, action);
break;
#endregion
#region 全部账单
case "allMon":
TradeLsit(context, action);
break;
#endregion
default:
break;
}
}
catch (Exception ex)
{
JsonObject json = new JsonObject();
json.Put(TAO_KEY_STATUS, TAO_STATUS_ERROR);
json.Put(TAO_KEY_DATA, ex);
context.Response.Write(json.ToString());
}
}
示例2: Invoke
public virtual object Invoke(string method, params object[] args)
{
WebRequest request = GetWebRequest(new Uri(Url));
request.Method = "POST";
using (Stream stream = request.GetRequestStream())
using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
{
JsonObject call = new JsonObject();
call["id"] = ++_id;
call["method"] = method;
call["params"] = args;
call.Export(new JsonTextWriter(writer));
}
using (WebResponse response = GetWebResponse(request))
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
JsonObject answer = new JsonObject();
answer.Import(new JsonTextReader(reader));
object errorObject = answer["error"];
if (errorObject != null)
OnError(errorObject);
return answer["result"];
}
}
示例3: BuildQuery
private string BuildQuery(JsonObject values)
{
List<string[]> pairs = new List<String[]>();
foreach (string k in values.Names)
{
AddValues(pairs, new List<string>(), k, values[k]);
}
StringBuilder result = new StringBuilder();
bool first = true;
foreach (string[] pair in pairs)
{
if (first)
{
first = false;
}
else
{
result.Append('&');
}
result.Append(HttpUtility.UrlEncode(pair[0]));
result.Append('=');
result.Append(HttpUtility.UrlEncode(pair[1]));
}
return result.ToString();
}
示例4: TorrentGetCommand
public TorrentGetCommand(JsonObject response)
{
Program.DaemonDescriptor.ResetFailCount();
if (!Program.Connected)
{
return;
}
JsonObject arguments = (JsonObject)response[ProtocolConstants.KEY_ARGUMENTS];
JsonArray torrents = (JsonArray)arguments[ProtocolConstants.KEY_TORRENTS];
Program.DaemonDescriptor.UpdateSerial++;
oldCount = Program.TorrentIndex.Count;
UpdateTorrents.Clear();
for (int i = 0; i < torrents.Count; i++)
{
JsonObject torrent = (JsonObject)torrents[i];
string hash = (string)torrent[ProtocolConstants.FIELD_HASHSTRING];
Torrent t = null;
lock (Program.TorrentIndex)
{
if (!Program.TorrentIndex.ContainsKey(hash))
{
t = new Torrent(torrent);
}
else
{
t = Program.TorrentIndex[hash];
if (t.Update(torrent, false))
stateChange = true;
}
UpdateTorrents.Add(t);
}
totalUpload += t.UploadRate;
totalDownload += t.DownloadRate;
}
}
示例5: ToString
public override string ToString()
{
JsonObject serialized = new JsonObject();
serialized.Put(KEY_MMSI, this.Mmsi);
serialized.Put(KEY_NAME, this.Name);
return serialized.ToString();
}
示例6: StaticUpdateStats
public static void StaticUpdateStats(JsonObject stats)
{
if (ClassSingleton<StatsDialog>.IsActive())
{
ClassSingleton<StatsDialog>.Instance.UpdateStats(stats);
}
}
示例7: FromRequest
public static JsonObject FromRequest(HttpRequest request)
{
//String methodName = request.getPathInfo().replaceAll("/", "");
JsonObject root = new JsonObject();
NameValueCollection parameters = request.Params;
root.Put("method", parameters["method"]);
if (!string.IsNullOrEmpty(parameters.Get("id")))
{
root.Put("id", parameters["id"]);
}
JsonObject paramsRoot = new JsonObject();
for (int i = 0; i < parameters.Count; i++)
{
if (!RESERVED_PARAMS.Contains(parameters.GetKey(i).ToLower()))
{
String[] path = parameters.GetKey(i).Split('\\');
JsonObject holder = BuildHolder(paramsRoot, path, 0);
holder.Put(path[path.Length - 1], ConvertToJsonValue(parameters.GetValues(i)[0]));
}
}
if (paramsRoot.Count > 0)
{
root.Put("params", paramsRoot);
}
return root;
}
示例8: UpdateStats
public void UpdateStats(JsonObject stats)
{
try
{
Toolbox.MaxSize ms = (Toolbox.MaxSize)(unitFactorComboBox.SelectedIndex + 1);
JsonObject sessionstats = (JsonObject)stats["current-stats"];
JsonObject cumulativestats = (JsonObject)stats["cumulative-stats"];
TimeSpan ts = TimeSpan.FromSeconds(Toolbox.ToLong(sessionstats["secondsActive"]));
downloadedBytesValue1.Text = Toolbox.GetFileSize(Toolbox.ToLong(sessionstats["downloadedBytes"]), ms);
uploadedBytesValue1.Text = Toolbox.GetFileSize(Toolbox.ToLong(sessionstats["uploadedBytes"]), ms);
filesAddedValue1.Text = ((JsonNumber)sessionstats["filesAdded"]).ToString();
sessionCountValue1.Text = ((JsonNumber)sessionstats["sessionCount"]).ToString();
secondsActiveValue1.Text = Toolbox.FormatTimespanLong(ts);
ts = TimeSpan.FromSeconds(Toolbox.ToLong(cumulativestats["secondsActive"]));
downloadedBytesValue2.Text = Toolbox.GetFileSize(Toolbox.ToLong(cumulativestats["downloadedBytes"]), ms);
uploadedBytesValue2.Text = Toolbox.GetFileSize(Toolbox.ToLong(cumulativestats["uploadedBytes"]), ms);
filesAddedValue2.Text = ((JsonNumber)cumulativestats["filesAdded"]).ToString();
sessionCountValue2.Text = ((JsonNumber)cumulativestats["sessionCount"]).ToString();
secondsActiveValue2.Text = ts.Ticks < 0 ? OtherStrings.UnknownNegativeResult : Toolbox.FormatTimespanLong(ts);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Unable to load stats data", MessageBoxButtons.OK, MessageBoxIcon.Error);
CloseAndDispose();
}
}
示例9: fromJson
public static ArchiveInfo fromJson(JsonObject jo)
{
try
{
ArchiveInfo info = new ArchiveInfo()
{
Name = jo["name"].ToString(),
Domain = jo["domain"].ToString(),
SupportHttp = Convert.ToBoolean(jo["http"]),
SupportHttps = Convert.ToBoolean(jo["https"]),
Software = "foolfuuka" == jo["software"].ToString() ? ArchiverSoftware.FoolFuuka : ArchiverSoftware.Fuuka
};
JsonArray boards = (JsonArray)jo["boards"];
foreach (string b in boards.Cast<string>())
{
info.AddPostBoard(b);
}
JsonArray files = (JsonArray)jo["files"];
foreach (string b in boards.Cast<string>())
{
info.AddFileBoard(b);
}
return info;
}
catch
{
return null;
}
}
示例10: RegisterUser
public void RegisterUser(JsonObject ps)
{
Profile p = new Profile();
ProfileManager pm = new ProfileManager();
FacebookService fb = new FacebookService();
Facebook.JsonObject o = fb.DownloadData<Facebook.JsonObject>("/me", ps["accessToken"].ToString());
if (pm.LoadUser(o["email"].ToString()) != null)
throw new Exception("Profile already exists");
p.CreationDate = DateTime.Now;
p.Email = o["email"].ToString();
p.IsLockedOut = false;
if (o.ContainsKey("username"))
p.UserName = o["username"].ToString();
else
p.UserName = ps["userID"].ToString();
pm.RegisterUser(p);
SocialConnection sc = new SocialConnection();
sc.OauthToken = ps["accessToken"].ToString();
sc.ReferenceID = ps["userID"].ToString();
sc.ServiceID = SocialServiceType.Facebook;
sc.UserID = p.UserID;
SocialServiceManager scm = new SocialServiceManager();
scm.AddConnection(sc);
pm.ReleaseAuthenticationTicket(p);
}
示例11: GetArtists
public Collection<ApiAudioArtist> GetArtists()
{
var artists = new Collection<ApiAudioArtist>();
var properties = new JsonArray(new[] { "thumbnail", "fanart", "description" });
var param = new JsonObject();
param["properties"] = properties;
var result = (JsonObject)_parent.JsonCommand("AudioLibrary.GetArtists", param);
if (result != null)
{
if (result.Contains("artists"))
{
foreach (JsonObject genre in (JsonArray)result["artists"])
{
try
{
var artist = new ApiAudioArtist
{
IdArtist = (long)(JsonNumber)genre["artistid"],
Name = genre["artist"].ToString(),
Thumb = genre["thumbnail"].ToString(),
Fanart = genre["fanart"].ToString(),
Biography = genre["description"].ToString()
};
artists.Add(artist);
}
catch (Exception)
{
}
}
}
}
return artists;
}
示例12: InitWithKeyValuePairs
public void InitWithKeyValuePairs()
{
JsonObject o = new JsonObject(new string[] { "one", "two", }, new object[] { 1, 2 });
Assert.AreEqual(2, o.Count);
Assert.AreEqual(1, o["one"]);
Assert.AreEqual(2, o["two"]);
}
示例13: JsonObject
public JsonObject(JsonObject jo, String[] names)
{
for (int i = 0; i < names.Length; i += 1)
{
PutOpt(names[i], jo.Opt(names[i]));
}
}
示例14: AsyncPlayFilesWorker
private void AsyncPlayFilesWorker(object sender, DoWorkEventArgs e)
{
var songs = (Collection<ApiAudioSong>)e.Argument;
if (songs == null)
return;
if (!_parent.IsConnected())
return;
_parent.JsonCommand("AudioPlaylist.Clear", null);
var i = 0;
var args = new JsonObject();
foreach (var apiAudioSong in songs)
{
if (((BackgroundWorker)sender).CancellationPending)
{
e.Cancel = true;
return;
}
args["songid"] = apiAudioSong.IdSong;
_parent.JsonCommand("AudioPlaylist.Add", args);
if (i != 0) continue;
_parent.JsonCommand("AudioPlaylist.Play", null);
i++;
}
}
示例15: GetGenres
public Collection<ApiAudioGenre> GetGenres()
{
var genres = new Collection<ApiAudioGenre>();
var properties = new JsonArray(new[] { "title", "thumbnail" });
var param = new JsonObject();
param["properties"] = properties;
var result = (JsonObject)_parent.JsonCommand("AudioLibrary.GetGenres", param);
if (result != null)
{
if (result.Contains("genres"))
{
foreach (JsonObject genre in (JsonArray)result["genres"])
{
try
{
var gen = new ApiAudioGenre
{
IdGenre = (long)(JsonNumber)genre["genreid"],
Name = genre["title"].ToString(),
AlbumCount = 0,
Thumb = genre["thumbnail"].ToString()
};
genres.Add(gen);
}
catch (Exception)
{
}
}
}
}
return genres;
}