当前位置: 首页>>代码示例>>C#>>正文


C# Json.JsonObject类代码示例

本文整理汇总了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());
            }
        }
开发者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


注:本文中的Jayrock.Json.JsonObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。