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


C# JsonObject类代码示例

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


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


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