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


C# JsonObject.Add方法代码示例

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


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

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

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

示例3: Add

 public void Add()
 {
     JsonObject o = new JsonObject();
     o.Add("foo", "bar");
     Assert.AreEqual("bar", o["foo"]);
     ICollection names = o.Names;
     Assert.AreEqual(1, names.Count);
     Assert.AreEqual(new string[] { "foo" }, CollectionHelper.ToArray(names, typeof(string)));
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:9,代码来源:TestJsonObject.cs

示例4: GetTvEpisodesRefresh

    public Collection<ApiTvEpisode> GetTvEpisodesRefresh()
    {
        var episodes = new Collection<ApiTvEpisode>();

        var properties = new JsonArray(new[] { "title", "plot", "season", "episode", "showtitle", "tvshowid", "fanart", "thumbnail", "rating", "playcount", "firstaired" });
        var param = new JsonObject();
        param["properties"] = properties;
        // First 100 Date sorted
        var param2 = new JsonObject();
        param2.Add("start", 0);
        param2.Add("end", 100);
        var param3 = new JsonObject();
        param3.Add("order", "descending");
        param3.Add("method", "dateadded");
        param.Add("sort", param3);
        param.Add("limits", param2);
        var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetEpisodes", param);

        if (result != null)
        {
            if (result.Contains("episodes"))
            {
                foreach (JsonObject genre in (JsonArray)result["episodes"])
                {
                    try
                    {
                        var tvShow = new ApiTvEpisode
                        {
                            Title = genre["title"].ToString(),
                            Plot = genre["plot"].ToString(),
                            Rating = genre["rating"].ToString(),
                            Mpaa = "",
                            Date = genre["firstaired"].ToString(),
                            Director = "",
                            PlayCount = 0,
                            Studio = "",
                            IdEpisode = (long)(JsonNumber)genre["episodeid"],
                            IdShow = (long)(JsonNumber)genre["tvshowid"],
                            Season = (long)(JsonNumber)genre["season"],
                            Episode = (long)(JsonNumber)genre["episode"],
                            Path = "",
                            ShowTitle = genre["showtitle"].ToString(),
                            Thumb = genre["thumbnail"].ToString(),
                            Fanart = genre["fanart"].ToString(),
                            Hash = Xbmc.Hash(genre["thumbnail"].ToString())
                        };
                        episodes.Add(tvShow);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
        return episodes;
    }
开发者ID:Ghawken,项目名称:FrontView,代码行数:56,代码来源:Xbmc.VideoLibrary.cs

示例5: CannotCopyToViaGenericCollectionWithTooSmallArray

 public void CannotCopyToViaGenericCollectionWithTooSmallArray()
 {
     ICollection<KeyValuePair<string, object>> obj = new JsonObject();
     obj.Add(new KeyValuePair<string, object>("foo", "bar"));
     obj.CopyTo(new KeyValuePair<string, object>[1], 1);
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:6,代码来源:TestJsonObject.cs

示例6: ContainsNonExistingViaGenericCollection

 public void ContainsNonExistingViaGenericCollection()
 {
     ICollection<KeyValuePair<string, object>> obj = new JsonObject();
     obj.Add(new KeyValuePair<string, object>("first", 123));
     Assert.IsFalse(obj.Contains(new KeyValuePair<string, object>("second", 456)));
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:6,代码来源:TestJsonObject.cs

示例7: AddViaGenericDictionary

 public void AddViaGenericDictionary()
 {
     IDictionary<string, object> obj = new JsonObject();
     Assert.AreEqual(0, obj.Count);
     obj.Add("one", 1);
     Assert.AreEqual(1, obj.Count);
     obj.Add("two", 2);
     Assert.AreEqual(2, obj.Count);
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:9,代码来源:TestJsonObject.cs

示例8: CannotAddDuplicateKeyViaGenericCollection

 public void CannotAddDuplicateKeyViaGenericCollection()
 {
     IDictionary<string, object> obj = new JsonObject();
     obj.Add(new KeyValuePair<string, object>("foo", "bar"));
     obj.Add(new KeyValuePair<string, object>("foo", "baz"));
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:6,代码来源:TestJsonObject.cs

示例9: ValuesViaGenericDictionary

 public void ValuesViaGenericDictionary()
 {
     IDictionary<string, object> obj = new JsonObject();
     obj.Add("first", 123);
     Assert.AreEqual(new object[] { 123 }, obj.Values);
     obj.Add("second", 456);
     Assert.AreEqual(new object[] { 123, 456 }, obj.Values);
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:8,代码来源:TestJsonObject.cs

示例10: GetTvShowsRefresh

    public Collection<ApiTvShow> GetTvShowsRefresh()
    {
        var shows = new Collection<ApiTvShow>();

        var properties = new JsonArray(new[] { "title", "art","plot", "genre", "fanart", "thumbnail", "rating", "mpaa", "studio", "playcount", "premiered", "episode", "file" });
        var param = new JsonObject();
        param["properties"] = properties;

        // First 100 Date sorted
        var param2 = new JsonObject();
        param2.Add("start", 0);
        param2.Add("end", 10);   //Number of TV Shows Quick Refresh Gets
        var param3 = new JsonObject();
        param3.Add("order", "descending");
        param3.Add("method", "dateadded");
        param.Add("sort", param3);
        param.Add("limits", param2);


        var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetTVShows", param);
        if (result != null)
        {
            if (result.Contains("tvshows"))
            {
                foreach (JsonObject genre in (JsonArray)result["tvshows"])
                {
                    try
                    {
                        var clearlogo = "NONE";
                        var banner = "NONE";
                            // go through art and see.

                        JsonObject results = (JsonObject)genre["art"];

                        if (results != null)
                        {
                                if (results["clearlogo"] != null)
                                {
                                    clearlogo = results["clearlogo"].ToString();
                                }
                                if (results["banner"] != null)
                                {
                                    banner = results["banner"].ToString();
                                }

                         }


                        var tvShow = new ApiTvShow
                        {
                            Title = genre["title"].ToString(),
                            Plot = genre["plot"].ToString(),
                            Rating = genre["rating"].ToString(),
                            IdScraper = "",
                            Mpaa = genre["mpaa"].ToString(),
                            Genre = _parent.JsonArrayToString((JsonArray)genre["genre"]),
                            Studio = _parent.JsonArrayToString((JsonArray)genre["studio"]),
                            IdShow = (long)(JsonNumber)genre["tvshowid"],
                            TotalCount = (long)(JsonNumber)genre["episode"],
                            Path = genre["file"].ToString(),
                            Premiered = genre["premiered"].ToString(),
                            Thumb = genre["thumbnail"].ToString(),
                            Fanart = genre["fanart"].ToString(),
                            Logo = clearlogo,
                            Banner = banner,
                            Hash = Xbmc.Hash(genre["thumbnail"].ToString())
                        };
                        shows.Add(tvShow);
                    }
                    catch (Exception ex)
                    {
                            _parent.Log("GetTVShowsRefresh : Exception Caught: Json seems to equal :" + ex);
                     }
                }
            }
        }
        return shows;
    }
开发者ID:Ghawken,项目名称:FrontView,代码行数:78,代码来源:Xbmc.VideoLibrary.cs

示例11: KeysViaGenericDictionary

 public void KeysViaGenericDictionary()
 {
     IDictionary<string, object> obj = new JsonObject();
     obj.Add("first", 123);
     Assert.AreEqual(new string[] { "first" }, obj.Keys);
     obj.Add("second", 456);
     Assert.AreEqual(new string[] { "first", "second" }, obj.Keys);
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:8,代码来源:TestJsonObject.cs

示例12: RemoveNonExistingViaGenericCollection

 public void RemoveNonExistingViaGenericCollection()
 {
     ICollection<KeyValuePair<string, object>> obj = new JsonObject();
     obj.Add(new KeyValuePair<string, object>("first", 123));
     Assert.AreEqual(1, obj.Count);
     Assert.IsFalse(obj.Remove(new KeyValuePair<string, object>("second", 456)));
     Assert.AreEqual(1, obj.Count);
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:8,代码来源:TestJsonObject.cs

示例13: GetMoviesRefresh

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

        var properties = new JsonArray(new[] { "title", "plot", "dateadded", "genre", "year", "fanart", "thumbnail", "playcount", "studio", "rating", "runtime", "mpaa", "originaltitle", "director", "votes" });
        var param = new JsonObject();
        param["properties"] = properties;
        // First 100 Date sorted
        var param2 = new JsonObject();
        param2.Add("start", 0);
        param2.Add("end", 100);
        var param3 = new JsonObject();
        param3.Add("order", "descending");
        param3.Add("method", "dateadded");
        param.Add("sort", param3);
        param.Add("limits", param2);


        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()),
                            DateAdded = genre["dateadded"].ToString()
                        };
                        movies.Add(movie);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }

        return movies;

    }
开发者ID:Ghawken,项目名称:FrontView,代码行数:66,代码来源:Xbmc.VideoLibrary.cs

示例14: CopyToViaGenericCollection

 public void CopyToViaGenericCollection()
 {
     ICollection<KeyValuePair<string, object>> obj = new JsonObject();
     KeyValuePair<string, object> first = new KeyValuePair<string, object>("first", 123);
     obj.Add(first);
     KeyValuePair<string, object> second = new KeyValuePair<string, object>("second", 456);
     obj.Add(second);
     KeyValuePair<string, object>[] pairs = new KeyValuePair<string, object>[2];
     obj.CopyTo(pairs, 0);
     Assert.AreEqual(first, pairs[0]);
     Assert.AreEqual(second, pairs[1]);
 }
开发者ID:atifaziz,项目名称:Jayrock,代码行数:12,代码来源:TestJsonObject.cs

示例15: GetTvShowsRefresh

    public Collection<ApiTvShow> GetTvShowsRefresh()
    {
        var shows = new Collection<ApiTvShow>();

        var properties = new JsonArray(new[] { "title", "plot", "genre", "fanart", "thumbnail", "rating", "mpaa", "studio", "playcount", "premiered", "episode" });
        var param = new JsonObject();
        param["properties"] = properties;

        // First 100 Date sorted
        var param2 = new JsonObject();
        param2.Add("start", 0);
        param2.Add("end", 10);
        var param3 = new JsonObject();
        param3.Add("order", "descending");
        param3.Add("method", "dateadded");
        param.Add("sort", param3);
        param.Add("limits", param2);


        var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetTVShows", param);
        if (result != null)
        {
            if (result.Contains("tvshows"))
            {
                foreach (JsonObject genre in (JsonArray)result["tvshows"])
                {
                    try
                    {
                        var tvShow = new ApiTvShow
                        {
                            Title = genre["title"].ToString(),
                            Plot = genre["plot"].ToString(),
                            Rating = genre["rating"].ToString(),
                            IdScraper = "",
                            Mpaa = genre["mpaa"].ToString(),
                            Genre = _parent.JsonArrayToString((JsonArray)genre["genre"]),
                            Studio = _parent.JsonArrayToString((JsonArray)genre["studio"]),
                            IdShow = (long)(JsonNumber)genre["tvshowid"],
                            TotalCount = (long)(JsonNumber)genre["episode"],
                            Path = "",
                            Premiered = genre["premiered"].ToString(),
                            Thumb = genre["thumbnail"].ToString(),
                            Fanart = genre["fanart"].ToString(),
                            Hash = Xbmc.Hash(genre["thumbnail"].ToString())
                        };
                        shows.Add(tvShow);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
        return shows;
    }   
开发者ID:Ghawken,项目名称:FrontView,代码行数:55,代码来源:Xbmc.VideoLibrary.cs


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