本文整理汇总了C#中Jayrock.Json.JsonArray类的典型用法代码示例。如果您正苦于以下问题:C# JsonArray类的具体用法?C# JsonArray怎么用?C# JsonArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JsonArray类属于Jayrock.Json命名空间,在下文中一共展示了JsonArray类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: GetTvSeasons
public Collection<ApiTvSeason> GetTvSeasons()
{
var seasons = new Collection<ApiTvSeason>();
var properties = new JsonArray(new[] { "title" });
var param = new JsonObject();
param["properties"] = properties;
var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetTVShows", param);
if (result != null)
{
if (result.Contains("tvshows"))
{
foreach (JsonObject show in (JsonArray)result["tvshows"])
{
var properties2 =
new JsonArray(new[] { "tvshowid", "fanart", "thumbnail", "season", "showtitle", "episode" });
var param2 = new JsonObject();
param2["properties"] = properties2;
param2["tvshowid"] = (long)(JsonNumber)show["tvshowid"];
var result2 = (JsonObject)_parent.JsonCommand("VideoLibrary.GetSeasons", param2);
if (result2 == null) continue;
if (!result2.Contains("seasons")) continue;
foreach (JsonObject genre in (JsonArray)result2["seasons"])
{
try
{
var tvShow = new ApiTvSeason
{
SeasonNumber = (long)(JsonNumber)genre["season"],
IdShow = (long)(JsonNumber)genre["tvshowid"],
Show = genre["showtitle"].ToString(),
Thumb = genre["thumbnail"].ToString(),
EpisodeCount = (long)(JsonNumber)genre["episode"],
Fanart = genre["fanart"].ToString(),
Hash = Xbmc.Hash(genre["thumbnail"].ToString())
};
seasons.Add(tvShow);
}
catch (Exception)
{
}
}
}
}
}
return seasons;
}
开发者ID:Ghawken,项目名称:FrontView,代码行数:47,代码来源:Xbmc.VideoLibrary.cs
示例17: Process
public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
{
if (request.UriPath.StartsWith(Url))
{
string day_number = request.QueryString[UrlParameters.DayNumber].Value;
int dayNumber = 0;
DateTime day = DateTime.Now;
if (Int32.TryParse(day_number, out dayNumber))
{
day = new DateTime(day.Year, 1, 1);
dayNumber--;
if (!DateTime.IsLeapYear(day.Year) && dayNumber == 365)
{
dayNumber--;
}
day = day.AddDays(dayNumber);
}
var sdata = NetworkUsageCounter.GetDayStats(day);
JsonArray ja = new JsonArray();
for (int i = 0; i < sdata.Length; i++)
{
double t = sdata[i].Value / 1024 / 1024;
JsonArray inner = new JsonArray();
inner.Add(sdata[i].Key);
inner.Add(Math.Round(t, 2, MidpointRounding.AwayFromZero));
ja.Add(inner);
}
WriteJsonResponse(response, ja.ToString());
return true;
}
return false;
}
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:46,代码来源:GetDailyNetworkStatisticsJsonApiHandler.cs
示例18: ImportIsExceptionSafe
public void ImportIsExceptionSafe()
{
JsonArray a = new JsonArray();
object o = new object();
a.Add(o);
try
{
a.Import(new JsonTextReader(new StringReader("[123,456,")));
}
catch (JsonException)
{
}
Assert.AreEqual(1, a.Count);
Assert.AreSame(o, a[0]);
}
开发者ID:BackupTheBerlios,项目名称:jayrock-svn,代码行数:17,代码来源:TestJsonArray.cs
示例19: Reannounce
public static JsonObject Reannounce(ReannounceMode mode, JsonArray ids)
{
JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENTREANNOUNCE);
JsonObject arguments = GetArgObject(request);
switch (mode)
{
case ReannounceMode.RecentlyActive:
arguments.Put(ProtocolConstants.KEY_IDS, ProtocolConstants.VALUE_RECENTLY_ACTIVE);
break;
case ReannounceMode.All:
arguments.Put(ProtocolConstants.KEY_IDS, new JsonArray());
break;
case ReannounceMode.Specific:
arguments.Put(ProtocolConstants.KEY_IDS, ids);
break;
}
return request;
}
开发者ID:bacobart,项目名称:transmission-remote-dotnet,代码行数:18,代码来源:Requests.cs
示例20: GetSignalsNearby
public JsonArray GetSignalsNearby(JsonObject param)
{
CheckRequest(param["ajaxSessionKey"].ToString());
JsonArray ar = new JsonArray();
SignalManager sm = new SignalManager();
List<Signal> ret = sm.SearchNearZip(param["zip"].ToString());
for (int i = 0; i < ret.Count; i++)
{
JsonObject obj = new JsonObject();
obj["signal"] = ret[i];
obj["description"] = GetSignalDescription(ret[i]);
ar.Push(obj);
}
return ar;
}
开发者ID:Lefeunoir,项目名称:mettiaposto,代码行数:19,代码来源:JSONService.ashx.cs
注:本文中的Jayrock.Json.JsonArray类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论