本文整理汇总了C#中Jayrock.Json.JsonObject类的典型用法代码示例。如果您正苦于以下问题:C# JsonObject类的具体用法?C# JsonObject怎么用?C# JsonObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonObject类属于Jayrock.Json命名空间,在下文中一共展示了JsonObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
}
}
开发者ID:bookxiao,项目名称:orisoft,代码行数:32,代码来源:TradeDetailsHandle.cs
示例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"];
}
}
开发者ID:bubbafat,项目名称:Hebo,代码行数:30,代码来源:JsonRpcClient.cs
示例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();
}
开发者ID:earth911,项目名称:search-api-sample-code-.net,代码行数:25,代码来源:Earth911.Api.cs
示例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;
}
}
开发者ID:bacobart,项目名称:transmission-remote-dotnet,代码行数:35,代码来源:TorrentGetCommand.cs
示例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();
}
开发者ID:ajf8,项目名称:marine-radio,代码行数:7,代码来源:AddressRecord.cs
示例6: StaticUpdateStats
public static void StaticUpdateStats(JsonObject stats)
{
if (ClassSingleton<StatsDialog>.IsActive())
{
ClassSingleton<StatsDialog>.Instance.UpdateStats(stats);
}
}
开发者ID:bacobart,项目名称:transmission-remote-dotnet,代码行数:7,代码来源:StatsDialog.cs
示例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;
}
开发者ID:s7loves,项目名称:pesta,代码行数:27,代码来源:JsonConversionUtil.cs
示例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();
}
}
开发者ID:bacobart,项目名称:transmission-remote-dotnet,代码行数:26,代码来源:StatsDialog.cs
示例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;
}
}
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:32,代码来源:ArchivesProvider.cs
示例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);
}
开发者ID:shardick,项目名称:ryller,代码行数:34,代码来源:UserService.cs
示例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;
}
开发者ID:Ghawken,项目名称:FrontView,代码行数:34,代码来源:Xbmc.AudioLibrary.cs
示例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"]);
}
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:7,代码来源:TestJsonObject.cs
示例13: JsonObject
public JsonObject(JsonObject jo, String[] names)
{
for (int i = 0; i < names.Length; i += 1)
{
PutOpt(names[i], jo.Opt(names[i]));
}
}
开发者ID:s7loves,项目名称:pesta,代码行数:7,代码来源:JsonObject.cs
示例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++;
}
}
开发者ID:Ghawken,项目名称:FrontView,代码行数:26,代码来源:Xbmc.AudioPlayer.cs
示例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;
}
开发者ID:Ghawken,项目名称:FrontView,代码行数:33,代码来源:Xbmc.AudioLibrary.cs
示例16: AsyncPlayFilesWorker
private void AsyncPlayFilesWorker(object sender, DoWorkEventArgs e)
{
var songs = (Collection<ApiAudioSong>)e.Argument;
if (songs == null)
return;
if (!_parent.IsConnected())
return;
var plId = new JsonObject();
plId["playlistid"] = 1;
_parent.JsonCommand("Playlist.Clear", plId);
var i = 0;
var args = new JsonObject();
var items = new JsonObject();
foreach (var apiAudioSong in songs)
{
if (((BackgroundWorker)sender).CancellationPending)
{
e.Cancel = true;
return;
}
args["songid"] = apiAudioSong.IdSong;
items["item"] = args;
items["playlistid"] = 1;
_parent.JsonCommand("Playlist.Add", items);
if (i != 0) continue;
var item = new JsonObject();
item["item"] = plId;
_parent.JsonCommand("Player.Open", item);
i++;
}
}
开发者ID:Ghawken,项目名称:FrontView,代码行数:33,代码来源:Xbmc.AudioPlayer.cs
示例17: Main
public static void Main(string[] args)
{
JsonWsp.Client cli = new JsonWsp.Client("http://10.1.5.160/service/AccessService/jsonwsp/description");
cli.SetViaProxy(true);
if (args.Length==0) {
Console.WriteLine("Usage: jsontest.exe <session_id>");
return;
}
Console.WriteLine("Call listPermissions");
Console.WriteLine("--------------------");
// Build arguments
JsonObject args_dict = new JsonObject();
args_dict.Add("session_id",args[0]);
// Call method
JsonObject result = CommonCall(cli,"listPermissions",args_dict);
if (result != null) {
Jayrock.Json.JsonArray perm = (Jayrock.Json.JsonArray) result["access_identifiers"];
foreach (string i in perm) {
Console.WriteLine(i);
}
}
Console.WriteLine();
Console.WriteLine("Call hasPermissions");
Console.WriteLine("-------------------");
// Build arguments
JsonObject args_dict2 = new JsonObject();
args_dict2.Add("session_id",args[0]);
args_dict2.Add("access_identifier","product.web.10finger");
// Call method
result = CommonCall(cli,"hasPermission",args_dict2);
// Print
if (result != null) {
bool access = (bool) result["has_permission"];
if (access) {
Console.WriteLine("Access Granted");
}
else {
Console.WriteLine("Access Denied");
}
}
Console.WriteLine();
Console.WriteLine("Call getUserInfo");
Console.WriteLine("----------------");
cli = new JsonWsp.Client("http://10.1.5.160/service/UserService/jsonwsp/description");
result = CommonCall(cli,"getUserInfo",args_dict);
if (result != null) {
JsonObject user_info = (JsonObject) result["user_info"];
Console.WriteLine("Org-name: " + user_info["org_name"]);
Console.WriteLine("Org-domain: " + user_info["org_domain"]);
Console.WriteLine("Org-code: " + user_info["org_code"]);
Console.WriteLine("Org-type: " + user_info["org_type"]);
Console.WriteLine("Given Name: " + user_info["given_name"]);
Console.WriteLine("Surname: " + user_info["surname"]);
Console.WriteLine("Uid: " + user_info["uid"]);
Console.WriteLine("Common-name: " + user_info["common_name"]);
}
}
开发者ID:mikrov,项目名称:jsonwsp-cs,代码行数:60,代码来源:Main.cs
示例18: Process
public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
{
if (request.UriPath.StartsWith(Url))
{
string hash = request.QueryString["hash"].Value;
if (string.IsNullOrEmpty(hash))
{
ThreadServerModule._404(response);
}
else
{
if (Program.queued_files.ContainsKey(hash))
{
FileQueueStateInfo f = Program.queued_files[hash];
JsonObject ob = new JsonObject();
ob.Add("p", f.Percent().ToString());
ob.Add("s", string.Format("{0} / {1}", Program.format_size_string(f.Downloaded), Program.format_size_string(f.Length)));
ob.Add("c", f.Status == FileQueueStateInfo.DownloadStatus.Complete);
WriteJsonResponse(response, ob.ToString());
}
else
{
ThreadServerModule._404(response);
}
}
return true;
}
return false;
}
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:35,代码来源:GetFileInfoJsonApiHandler.cs
示例19: PeerListViewItem
public PeerListViewItem(JsonObject peerObj)
: base((string)peerObj[ProtocolConstants.ADDRESS])
{
for (int i = 0; i < 7; i++)
base.SubItems.Add("");
this.Address = base.Name = base.Text;
int countryIndex = -1;
if (!GeoIPCountry.Disabled)
{
try
{
countryIndex = GeoIPCountry.Instance.FindIndex(this.IpAddress);
}
catch { }
}
if (countryIndex > 0)
this.Country = GeoIPCountry.CountryNames[countryIndex];
this.ClientName = (string)peerObj[ProtocolConstants.FIELD_CLIENTNAME];
this.Update(peerObj);
if (countryIndex > 0)
{
base.ImageIndex = GeoIPCountry.FlagImageList.Images.IndexOfKey("flags_" + GeoIPCountry.CountryCodes[countryIndex].ToLower());
}
Dns.BeginGetHostEntry(this.IpAddress, new AsyncCallback(GetHostEntryCallback), this);
}
开发者ID:bacobart,项目名称:transmission-remote-dotnet,代码行数:25,代码来源:PeerListViewItem.cs
示例20: FromException
public static JsonObject FromException(Exception e, bool includeStackTrace)
{
if (e == null)
throw new ArgumentNullException("e");
JsonObject error = new JsonObject();
error.Put("name", "JSONRPCError");
error.Put("message", e.GetBaseException().Message);
if (includeStackTrace)
error.Put("stackTrace", e.StackTrace);
JsonArray errors = new JsonArray();
do
{
errors.Put(ToLocalError(e));
e = e.InnerException;
}
while (e != null);
error.Put("errors", errors);
return error;
}
开发者ID:db48x,项目名称:KeeFox,代码行数:25,代码来源:JsonRpcError.cs
注:本文中的Jayrock.Json.JsonObject类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论