• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# JsonObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ProcessSub

 protected override void ProcessSub(HttpContext context, string uploadPath, string fileName)
 {
     JsonObject obj2 = new JsonObject();
     obj2.Put("data", uploadPath + "T_" + fileName);
     obj2.Put("success", true);
     context.Response.Write(obj2.ToString());
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:7,代码来源:UploadGravatarHandler.cs


示例2: Append

 public override void Append(JsonSchemaRuleComponent rules, JsonObject definition, Func<JsonObject, JsonSchemaRule> parse)
 {
     if (definition.Contains<JsonTrue>("uniqueItems"))
     {
         rules.Add(new JsonUniqueItemsRule());
     }
 }
开发者ID:amacal,项目名称:jinx,代码行数:7,代码来源:JsonUniqueItemsRuleFactory.cs


示例3: serializeObject

        private static JsonObject serializeObject(object obj)
        {
            PropertyInfo[] propInfo = obj.GetType().GetProperties();
            string propertyName;
            object propertyValue;
            JsonValueType type;

            JsonObject o = new JsonObject(propInfo.Length);
            foreach (var p in propInfo)
            {
                propertyName = p.Name;
                propertyValue = p.GetValue(obj);
                type = JsonValue.GetPrimitiveType(p.PropertyType);
                if (type == JsonValueType.Object)
                {
                    JsonObject o2 = serializeObject(propertyValue);
                    o.Add(propertyName, o2);
                    continue;
                }
                else if (type == JsonValueType.Array)
                {
                    JsonArray a = serializeArray((IEnumerable)propertyValue);
                    o.Add(propertyName, a);
                    continue;
                }
                else
                {
                    string value = propertyValue.ToString();
                    JsonPrimitive primitive = new JsonPrimitive(value, type);
                    o.Add(propertyName, primitive);
                }
            }
            return o;
        }
开发者ID:392HEMI,项目名称:Api,代码行数:34,代码来源:JsonSerializer.cs


示例4: InvokeOnEvent

        /// <summary>
        /// If the event exists,invoke the event when server return messge.
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        ///
        public void InvokeOnEvent(string route, JsonObject msg)
        {
            if(!this.eventMap.ContainsKey(route)) return;

            List<Action<JsonObject>> list = eventMap[route];
            foreach(Action<JsonObject> action in list) action.Invoke(msg);
        }
开发者ID:lzxm160,项目名称:pomelo-chat-demo,代码行数:14,代码来源:EventManager.cs


示例5: AddRuleProduct

 private string AddRuleProduct(HttpContext context)
 {
     JsonObject obj2 = new JsonObject();
     int num = Convert.ToInt32(context.Request.Form["ProductId"]);
     int ruleId = Convert.ToInt32(context.Request.Form["RuleId"]);
     string str = context.Request.Form["ProductName"];
     if (this.ruleProductBll.Exists(ruleId, (long) num))
     {
         obj2.Put("STATUS", "Presence");
         return obj2.ToString();
     }
     Maticsoft.Model.Shop.Sales.SalesRuleProduct model = new Maticsoft.Model.Shop.Sales.SalesRuleProduct {
         ProductId = num,
         RuleId = ruleId,
         ProductName = str
     };
     if (this.ruleProductBll.Add(model))
     {
         obj2.Put("STATUS", "SUCCESS");
         obj2.Put("DATA", "Approve");
         return obj2.ToString();
     }
     obj2.Put("STATUS", "NODATA");
     return obj2.ToString();
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:25,代码来源:ShopHandler.cs


示例6: DeleteBrands

 private void DeleteBrands(HttpContext context)
 {
     JsonObject obj2 = new JsonObject();
     string str = context.Request.Params["idList"];
     if (!string.IsNullOrWhiteSpace(str))
     {
         Maticsoft.BLL.Shop.Products.BrandInfo info = new Maticsoft.BLL.Shop.Products.BrandInfo();
         Maticsoft.BLL.Shop.Products.ProductInfo info2 = new Maticsoft.BLL.Shop.Products.ProductInfo();
         Maticsoft.BLL.Shop.Products.ProductTypeBrand brand = new Maticsoft.BLL.Shop.Products.ProductTypeBrand();
         int brandId = Globals.SafeInt(str, 0);
         if (info2.ExistsBrands(brandId))
         {
             obj2.Put("STATUS", "FAILED");
             obj2.Put("DATA", "该品牌正在使用中!");
         }
         if (info.DeleteList(str))
         {
             brand.Delete(null, new int?(brandId));
             obj2.Put("STATUS", "SUCCESS");
         }
         else
         {
             obj2.Put("STATUS", "FAILED");
             obj2.Put("DATA", "系统忙,请稍后再试!");
         }
     }
     else
     {
         obj2.Put("STATUS", "FAILED");
         obj2.Put("DATA", "系统忙,请稍后再试!");
     }
     context.Response.Write(obj2.ToString());
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:33,代码来源:ShopHandler.cs


示例7: Parse

 public static FacebookObject Parse(JsonObject obj) {
     if (obj == null) return null;
     return new FacebookObject(obj) {
         Id = obj.GetString("id"),
         Name = obj.GetString("name")
     };
 }
开发者ID:EmilMoe,项目名称:Skybrud.Social,代码行数:7,代码来源:FacebookObject.cs


示例8: Run

        public static void Run()
        {
            //TODO: Fix this up with a request wrapper
            dynamic googleSearch = new RestClient(null, Services.GoogleSearchUri, RestService.Json);

            Console.WriteLine("Searching Google for 'seattle'...");

            dynamic searchOptions = new JsonObject();
            searchOptions.q = "seattle";

            dynamic search = googleSearch.invokeAsync(searchOptions);
            search.Callback((RestCallback)delegate() {
                dynamic results = search.Result.responseData.results;
                foreach (dynamic item in results) {
                    Console.WriteLine(item.titleNoFormatting);
                    Console.WriteLine(item.url);
                    Console.WriteLine();
                }
            });

            while (search.IsCompleted == false) {
                Console.WriteLine(".");
                Thread.Sleep(100);
            }
        }
开发者ID:ioulia,项目名称:dynamicrest,代码行数:25,代码来源:GoogleSearchSample.cs


示例9: Update

 //note the async keyword - it's cause we're using an "await" method in our method body
 public async void Update()
 {
     var client = new HttpClient();
     //ooh fancy new await syntax!
     //this actually executes in parallel and pauses the rest of the method's execution until it returns
     //(in a non blocking way of course)
     var result = await client.GetAsync(string.Format("http://search.twitter.com/search.json?q={0}&since_id={1}", SearchTerm, Since));
     var root = new JsonObject(result.Content.ReadAsString());
     var array = root.GetNamedArray("results");
     for(int i = 0; i < array.Count; i++) 
     {
         var element = array[i];
         JsonObject obj = element.GetObject();
         Tweet tweet = new Tweet
         {
             created_at = obj.GetNamedString("created_at"),
             from_user = obj.GetNamedString("from_user"),
             id_str = obj.GetNamedString("id_str"),
             profile_image_url = obj.GetNamedString("profile_image_url"),
             text = obj.GetNamedString("text")
         };
         if (!Tweets.Any(t => t.id_str == tweet.id_str))
         {
             Tweets.Insert(0, tweet);
         }
     }
 }
开发者ID:ChadMcCallum,项目名称:Windows8Examples,代码行数:28,代码来源:TwitterSearchModel.cs


示例10: CreateJsonTest

    private void CreateJsonTest()
    {
        JsonArray weekDiet = new JsonArray();
        for(int i=0;i<7;i++)
        {
            JsonObject diet = new JsonObject();
            diet["DayNumber"] = i;
            diet["Breakfast"] = "Banana"+ i;
            diet["Lunch"] = "Banana"+ i;
            diet["Dinner"] = "Banana"+ i;
            diet["WithSugar"] = (i % 2 == 0);
            diet["RandomNumber"] = Random.Range(0f,1.5f);

            weekDiet.Add(diet);
        }

        for (int i=0;i<7;i++)
        {
            if (i % 2 == 1)
            {
                weekDiet[i]["RandomNumber"] = 3;
                weekDiet[i]["RandomNumber"] = weekDiet[i]["RandomNumber"] * 2f;
            }
        }

        Debug.Log("Test InputOutputFileTest done: \n"+ weekDiet.ToJsonPrettyPrintString());
    }
开发者ID:Raysangar,项目名称:NiceJson,代码行数:27,代码来源:JsonTest.cs


示例11: GetCategoryInfo

 public void GetCategoryInfo(HttpContext context)
 {
     Func<Maticsoft.Model.SNS.Categories, bool> predicate = null;
     string categoryId = context.Request.Params["CID"];
     int type = Globals.SafeInt(context.Request.Params["Type"], 0);
     JsonObject obj2 = new JsonObject();
     if (!string.IsNullOrWhiteSpace(categoryId))
     {
         if (predicate == null)
         {
             predicate = c => c.ParentID == Globals.SafeInt(categoryId, 0);
         }
         List<Maticsoft.Model.SNS.Categories> list2 = this.SNSCateBll.GetAllCateByCache(type).Where<Maticsoft.Model.SNS.Categories>(predicate).ToList<Maticsoft.Model.SNS.Categories>();
         if ((list2 != null) && (list2.Count > 0))
         {
             JsonArray data = new JsonArray();
             list2.ForEach(delegate (Maticsoft.Model.SNS.Categories info) {
                 data.Add(new JsonObject(new string[] { "CategoryId", "Name", "ParentID", "HasChildren" }, new object[] { info.CategoryId, info.Name, info.ParentID, info.HasChildren }));
             });
             obj2.Put("STATUS", "Success");
             obj2.Put("DATA", data);
         }
         else
         {
             obj2.Put("STATUS", "Fail");
         }
     }
     else
     {
         obj2.Put("STATUS", "Error");
     }
     context.Response.Write(obj2.ToString());
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:33,代码来源:CategoriesHandler.cs


示例12: LoadState

        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }

            Geolocator locator = new Geolocator();
            Geoposition geoPos = await locator.GetGeopositionAsync();
            Geocoordinate geoCoord = geoPos.Coordinate;

            String YWSID = "Bi9Fsbfon92vmD4DkkO4Fg";
            String url;

            if (navigationParameter != "")
            {
                url = "http://api.yelp.com/business_review_search?term=food&location=" + navigationParameter + "&ywsid=" + YWSID;
            }
            else
            {
                url = "http://api.yelp.com/business_review_search?term=food&lat=" + geoCoord.Latitude + "&long=" + geoCoord.Longitude + "&ywsid=" + YWSID;
            }
            var httpClient = new HttpClient();
            String content = await httpClient.GetStringAsync(url);
            response = JsonObject.Parse(content);

            this.Frame.Navigate(typeof(MainPage),response);
        }
开发者ID:Hitchhikrr,项目名称:psucampapp,代码行数:38,代码来源:LoadingScreen.xaml.cs


示例13: Parse

 public static TwitterHashTagEntitity Parse(JsonObject entity) {
     return new TwitterHashTagEntitity {
         Text = entity.GetString("text"),
         StartIndex = entity.GetArray("indices").GetInt(0),
         EndIndex = entity.GetArray("indices").GetInt(1)
     };
 }
开发者ID:jesperordrup,项目名称:Skybrud.Social,代码行数:7,代码来源:TwitterHashTagEntity.cs


示例14: PostJSON

    public void PostJSON( string inURL, JsonObject inJSON, Action< string, JsonObject > inCallback )
    {
        var headers = new Dictionary< string, string >();
        headers[ "Content-Type" ] = "application/json";

        var jsonString = SimpleJson.SimpleJson.SerializeObject( inJSON );
        Post( inURL, System.Text.Encoding.UTF8.GetBytes( jsonString ), headers, ( string inError, WWW inWWW ) =>
        {
            if( inCallback != null )
            {
                JsonObject obj = null;
                if ( string.IsNullOrEmpty( inError ) && ! string.IsNullOrEmpty( inWWW.text ) )
                {
                    Debug.Log("Response: " + inWWW.text );

                    object parsedObj = null;
                    if ( SimpleJson.SimpleJson.TryDeserializeObject( inWWW.text, out parsedObj ) )
                    {
                        obj = ( JsonObject ) parsedObj;
                    }
                }

                inCallback( inError, obj );
            }
        } );
    }
开发者ID:paleonluna,项目名称:ASAGoSailingApp,代码行数:26,代码来源:Rester.cs


示例15: JsonObjectConstructorParmsTest

        public void JsonObjectConstructorParmsTest()
        {
            JsonObject target = new JsonObject();
            Assert.Equal(0, target.Count);

            string key1 = AnyInstance.AnyString;
            string key2 = AnyInstance.AnyString2;
            JsonValue value1 = AnyInstance.AnyJsonValue1;
            JsonValue value2 = AnyInstance.AnyJsonValue2;

            List<KeyValuePair<string, JsonValue>> items = new List<KeyValuePair<string, JsonValue>>()
            {
                new KeyValuePair<string, JsonValue>(key1, value1),
                new KeyValuePair<string, JsonValue>(key2, value2),
            };

            target = new JsonObject(items[0], items[1]);
            Assert.Equal(2, target.Count);
            ValidateJsonObjectItems(target, key1, value1, key2, value2);

            target = new JsonObject(items.ToArray());
            Assert.Equal(2, target.Count);
            ValidateJsonObjectItems(target, key1, value1, key2, value2);

            // Invalid tests
            items.Add(new KeyValuePair<string, JsonValue>(key1, AnyInstance.DefaultJsonValue));
            ExceptionHelper.Throws<ArgumentException>(delegate { new JsonObject(items[0], items[1], items[2]); });
            ExceptionHelper.Throws<ArgumentException>(delegate { new JsonObject(items.ToArray()); });
        }
开发者ID:haoduotnt,项目名称:aspnetwebstack,代码行数:29,代码来源:JsonObjectTest.cs


示例16: FromJsonObject

		/// <summary>
		/// Constructs a ModuleDescriptor from a Json object
		/// </summary>
		/// <param name="InObject"></param>
		/// <returns>The new module descriptor</returns>
		public static ModuleDescriptor FromJsonObject(JsonObject InObject)
		{
			ModuleDescriptor Module = new ModuleDescriptor(InObject.GetStringField("Name"), InObject.GetEnumField<ModuleHostType>("Type"));

			ModuleLoadingPhase LoadingPhase;
			if (InObject.TryGetEnumField<ModuleLoadingPhase>("LoadingPhase", out LoadingPhase))
			{
				Module.LoadingPhase = LoadingPhase;
			}

			UnrealTargetPlatform[] WhitelistPlatforms;
			if (InObject.TryGetEnumArrayField<UnrealTargetPlatform>("WhitelistPlatforms", out WhitelistPlatforms))
			{
				Module.WhitelistPlatforms = WhitelistPlatforms;
			}

			UnrealTargetPlatform[] BlacklistPlatforms;
			if (InObject.TryGetEnumArrayField<UnrealTargetPlatform>("BlacklistPlatforms", out BlacklistPlatforms))
			{
				Module.BlacklistPlatforms = BlacklistPlatforms;
			}

			string[] AdditionalDependencies;
			if (InObject.TryGetStringArrayField("AdditionalDependencies", out AdditionalDependencies))
			{
				Module.AdditionalDependencies = AdditionalDependencies;
			}

			return Module;
		}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:35,代码来源:ModuleDescriptor.cs


示例17: ReadValue

 private void ReadValue(JsonObject input)
 {
     if (input == null)
         writer.WriteNull();
     else
         input.Accept(this);
 }
开发者ID:soxtoby,项目名称:ForSerial,代码行数:7,代码来源:JsonObjectReader.cs


示例18: MsgEncoder

        public MsgEncoder(JsonObject protos)
        {
            if (protos == null) protos = new JsonObject();

            this.protos = protos;
            this.util = new Util();
        }
开发者ID:jiangzhuo,项目名称:mwClient,代码行数:7,代码来源:MsgEncoder.cs


示例19: Parse

 public static TwitterReverseGeocodeQuery Parse(TwitterReverseGeocodeResults results, JsonObject obj) {
     return new TwitterReverseGeocodeQuery(obj) {
         Results = results,
         Url = obj.GetString("url"),
         Type = obj.GetString("type")
     };
 }
开发者ID:EmilMoe,项目名称:Skybrud.Social,代码行数:7,代码来源:TwitterReverseGeocodeQuery.cs


示例20: encode

    /// <summary>
    /// Encode the messge with id, route and jsonObject.
    /// </summary>
    /// <param name='id'>
    /// Identifier.
    /// </param>
    /// <param name='route'>
    /// Route.
    /// </param>
    /// <param name='jsonObject'>
    /// Json object.
    /// </param>
    /// <exception cref='System.ArgumentException'>
    /// Is thrown when the argument exception.
    /// </exception>
    public static string encode(int id, string route, JsonObject jsonObject)
    {
        if (route.Length > 255) {
            throw new System.ArgumentException("route maxlength is overflow");
        }

        byte[] byteArray = new byte[HEADER + route.Length];
        int index = 0;
        byteArray[index++] = Convert.ToByte((id >> 24) & 0xFF);
        byteArray[index++] = Convert.ToByte((id >> 16) & 0xFF);
        byteArray[index++] = Convert.ToByte((id >> 8) & 0xFF);
        byteArray[index++] = Convert.ToByte(id & 0xFF);
        byteArray[index++] = Convert.ToByte(route.Length & 0xFF);

        char[] routeArray = route.ToCharArray();
        int routeLength = routeArray.Length;
        for(int i = 0; i < routeLength; i++) {
            byteArray[index++] = Convert.ToByte(routeArray[i]);
        }
        string encodeString = "";
        try{
            encodeString = Encoding.UTF8.GetString(byteArray);
        }catch(Exception e){
            Console.WriteLine(string.Format("Error in new Encoding.UTF8.GetString:{0}", e.Message));
        }
        return encodeString + jsonObject.ToString();
    }
开发者ID:rpallas,项目名称:gws,代码行数:42,代码来源:Protocol.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JsonPatchDocument类代码示例发布时间:2022-05-24
下一篇:
C# JsonDeserializer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap