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


C# Json.JsonArray类代码示例

本文整理汇总了C#中Jayrock.Json.JsonArray的典型用法代码示例。如果您正苦于以下问题:C# JsonArray类的具体用法?C# JsonArray怎么用?C# JsonArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JsonArray类属于Jayrock.Json命名空间,在下文中一共展示了JsonArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (request.UriPath == Url)
            {
                ThreadStore.UpdateThreadStoreStats();
                ThreadStoreStats stats = ThreadStore.StoreStats;

                JsonArray ja = new JsonArray();

                IEnumerable<string> boards = Program.ValidBoards.Keys;

                for (int i = 0, j = boards.Count(); i < j; i++)
                {
                    string boardName = boards.ElementAt(i);
                    int threadCount = stats[boardName];

                    if (threadCount > 0)
                    {
                        JsonArray inner = new JsonArray();

                        inner.Add(boardName);
                        inner.Add(threadCount);

                        ja.Add(inner);
                    }
                }

                WriteJsonResponse(response, ja.ToString());
                return true;
            }

            return false;
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:33,代码来源:GetThreadsStatisticsJsonApiHandler.cs

示例2: 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

示例3: AddNullValueViaIList

 public void AddNullValueViaIList()
 {
     IList list = new JsonArray();
     list.Add(null);
     Assert.AreEqual(1, list.Count);
     Assert.IsNull(list[0]);
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:7,代码来源:TestJsonArray.cs

示例4: 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

示例5: 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

示例6: AddNullValue

 public void AddNullValue()
 {
     JsonArray a = new JsonArray();
     a.Add(null);
     Assert.AreEqual(1, a.Count);
     Assert.IsNull(a[0]);
 }
开发者ID:bubbafat,项目名称:Hebo,代码行数:7,代码来源:TestJsonArray.cs

示例7: ContentsClearedBeforeImporting

 public void ContentsClearedBeforeImporting()
 {
     JsonArray a = new JsonArray();
     a.Add(new object());
     Assert.AreEqual(1, a.Length);
     a.Import(new JsonTextReader(new StringReader("[123]")));
     Assert.AreEqual(1, a.Length);
 }
开发者ID:bubbafat,项目名称:Hebo,代码行数:8,代码来源:TestJsonArray.cs

示例8: TorrentSetLocation

 public static JsonObject TorrentSetLocation(JsonArray ids, string location, bool move)
 {
     JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENT_SET_LOCATION, ResponseTag.DoNothing);
     JsonObject args = GetArgObject(request);
     args.Put(ProtocolConstants.KEY_IDS, ids);
     args.Put(ProtocolConstants.FIELD_LOCATION, location);
     args.Put(ProtocolConstants.FIELD_MOVE, move);
     return request;
 }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:9,代码来源:Requests.cs

示例9: Import

 public void Import()
 {
     JsonArray a = new JsonArray();
     a.Import(new JsonTextReader(new StringReader("[123,'Hello World',true]")));
     Assert.AreEqual(3, a.Length);
     Assert.AreEqual(123, (int) (JsonNumber) a[0]);
     Assert.AreEqual("Hello World", a[1]);
     Assert.AreEqual(true, a[2]);
 }
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:9,代码来源:TestJsonArray.cs

示例10: Generic

        public static JsonObject Generic(string method, JsonArray ids)
        {
            JsonObject request = CreateBasicObject(method);
            JsonObject args = GetArgObject(request);
            if (ids != null)
                args.Put(ProtocolConstants.KEY_IDS, ids);

            return request;
        }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:9,代码来源:Requests.cs

示例11: RemoveTorrent

        public static JsonObject RemoveTorrent(JsonArray ids, bool delete)
        {
            JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENTREMOVE);
            JsonObject arguments = GetArgObject(request);
            if (delete && Program.DaemonDescriptor.Version >= 1.5)
                arguments.Put(ProtocolConstants.FIELD_DELETELOCALDATA, true);

            arguments.Put(ProtocolConstants.KEY_IDS, ids);
            return request;
        }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:10,代码来源:Requests.cs

示例12: GetString

        public override string GetString(IEnumerable<IFreeDocument> datas)
        {
            var nodeGroup = new JsonArray();

            foreach (IFreeDocument data in datas)
            {

                nodeGroup.Add(GetJsonObject(data));
            }
            return nodeGroup.ToString();
        }
开发者ID:CHERRISHGRY,项目名称:Hawk,代码行数:11,代码来源:FileConnectorJson.cs

示例13: Pop

 private void Pop()
 {
     object current = _value;
     object popped = _valueStack.Pop();
     _member = (string) _memberStack.Pop();
     if (popped == null) // Final result?
         return;
     _object = popped as JsonObject;
     _array = _object == null ? (JsonArray) popped : null;
     _value = popped;
     WriteValue(current);
 }
开发者ID:RyanWangTHU,项目名称:ccv2,代码行数:12,代码来源:JsonImportingWriter.cs

示例14: GetMovies

        public Collection<ApiMovie> GetMovies()
        {
            var movies = new Collection<ApiMovie>();

              var properties = new JsonArray(new[] { "title", "plot", "genre", "year", "fanart", "thumbnail", "playcount", "studio", "rating", "runtime", "mpaa", "originaltitle", "director", "votes" });
              var param = new JsonObject();
              param["properties"] = properties;
              var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetMovies", param);
              if (result != null)
              {
            if (result.Contains("movies"))
            {
              foreach (JsonObject genre in (JsonArray)result["movies"])
              {
            try
            {
              var t = TimeSpan.FromSeconds((long)(JsonNumber)genre["runtime"]);
              var duration = string.Format("{0:D2}:{1:D2}", t.Hours, t.Minutes);
              var movie = new ApiMovie
                {

                  Title = genre["title"].ToString(),
                  Plot = genre["plot"].ToString(),
                  Votes = genre["votes"].ToString(),
                  Rating = genre["rating"].ToString(),
                  Year = (long)(JsonNumber)genre["year"],
                  IdScraper = "",
                  Length = duration,
                  Mpaa = genre["mpaa"].ToString(),
                  Genre = _parent.JsonArrayToString((JsonArray)genre["genre"]),
                  Director = _parent.JsonArrayToString((JsonArray)genre["director"]),
                  OriginalTitle = genre["originaltitle"].ToString(),
                  Studio = _parent.JsonArrayToString((JsonArray)genre["studio"]),
                  IdFile = 0,
                  IdMovie = (long)(JsonNumber)genre["movieid"],
                  FileName = "",
                  Path = "",
                  PlayCount = 0,
                  Thumb = genre["thumbnail"].ToString(),
                  Fanart = genre["fanart"].ToString(),
                  Hash = Xbmc.Hash(genre["thumbnail"].ToString())
                };
              movies.Add(movie);
            }
            catch (Exception)
            {
            }
              }
            }
              }

              return movies;
        }
开发者ID:GroupXTech,项目名称:Yatse2,代码行数:53,代码来源:Xbmc.VideoLibrary.cs

示例15: Export

 public void Export()
 {
     JsonArray a = new JsonArray(new object[] { 123, "Hello World", true });
     JsonRecorder writer = new JsonRecorder();
     a.Export(writer);
     JsonReader reader = writer.CreatePlayer();
     reader.ReadToken(JsonTokenClass.Array);
     Assert.AreEqual(a[0], reader.ReadNumber().ToInt32());
     Assert.AreEqual(a[1], reader.ReadString());
     Assert.AreEqual(a[2], reader.ReadBoolean());
     reader.ReadToken(JsonTokenClass.EndArray);
 }
开发者ID:bubbafat,项目名称:Hebo,代码行数:12,代码来源:TestJsonArray.cs


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