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


C# JsonArray.ToString方法代码示例

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


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

示例1: MakeJsonObj

        public static string MakeJsonObj(string propertyName, JsonArray propertyValue, bool isString = false)
        {
            string str;
            if (isString)
            {
                str = string.Format("\\\"{0}\\\":{1}", propertyName, propertyValue.ToString());
            }
            else str = string.Format("\"{0}\":{1}", propertyName, propertyValue.ToString());

            return str;
        }
开发者ID:liqinghuang,项目名称:JP.Utils.UWP,代码行数:11,代码来源:JsonMaker.cs

示例2: LoadData

        protected void LoadData()
        {
            if (isLoading)
                return;

            Task.Factory.StartNew (() => {

                isLoading = true;

                while (lastKnownLocation == null && !this.IsFinishing)
                    Thread.Sleep(2000);

                if (this.lastKnownLocation != null && !this.IsFinishing)
                {
                    poiData = GeoUtils.GetPoiInformation(lastKnownLocation, 20);

                    var js = "World.loadPoisFromJsonData(" + poiData.ToString() + ");";

                    architectView.CallJavascript(js);
                }

                isLoading = false;

            }).ContinueWith (t => {

                isLoading = false;

                var ex = t.Exception;
                Log.Error(Constants.LOG_TAG, ex.ToString());

            }, TaskContinuationOptions.OnlyOnFaulted);
        }
开发者ID:Wikitude,项目名称:wikitude-xamarin,代码行数:32,代码来源:SamplePoidataFromNativeActivity.cs

示例3: GET

        public override ActionResult GET(System.Net.HttpListenerContext context, string httpActionPath)
        {
            JsonArray files = new JsonArray();
            files.AddRange(
                FileRepository.GetFiles()
                .Select(f => (JsonValue)new JsonObject {
                    { "Name", f.Name },
                    { "Size", f.Length },
                    { "Type", f.Extension },
                    { "Url", "/files/" + f.Name }
                })
            );

            var result = new ActionResult();
            result.Data = System.Text.Encoding.UTF8.GetBytes(files.ToString());
            result.ContentType = "application/json";
            return result;
        }
开发者ID:narent,项目名称:AirFolio,代码行数:18,代码来源:FilesAction.cs

示例4: GetUserName

 public string GetUserName(string prefixText, int limit)
 {
     if (string.IsNullOrWhiteSpace(prefixText))
     {
         return string.Empty;
     }
     string strUName = this.HtmlEncode(prefixText);
     DataSet userName = new UsersExp().GetUserName(strUName, limit);
     JsonArray array = new JsonArray();
     if (userName.Tables[0].Rows.Count > 0)
     {
         for (int i = 0; i < userName.Tables[0].Rows.Count; i++)
         {
             string tmpStr = userName.Tables[0].Rows[i]["UserName"].ToString();
             if (this.CheckHtmlCode(ref tmpStr, prefixText))
             {
                 JsonObject obj2 = new JsonObject();
                 obj2.Accumulate("name", tmpStr);
                 array.Add(obj2);
             }
         }
     }
     return array.ToString();
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:24,代码来源:GetData.cs

示例5: OrdersListByDatesToJson

 private string OrdersListByDatesToJson(List<Order> allOrders, DateTime startDate, DateTime endDate)
 {
     dynamic json_all_orders = new JsonArray();
     for (int i = 0; i < endDate.Subtract(startDate).Days; i++)
     {
         var day_ = startDate.AddDays(i);
         dynamic day = new JsonObject();
         day.Date = day_;
         day.Orders = new JsonArray();
         foreach (var order in allOrders.Where(o => o.Date.Day == day_.Day && o.Date.Month == day_.Month && o.Date.Year == day_.Year))
             day.Orders.Add(GetOrderJsonValue(order));
         json_all_orders.Add(day);
     }
     return json_all_orders.ToString();
 }
开发者ID:duda92,项目名称:javascript,代码行数:15,代码来源:OrdersController.cs

示例6: GetAllOrderModelsForDates

        public string GetAllOrderModelsForDates(int start_date_day, int start_date_month, int start_date_year, int end_date_day, int end_date_month, int end_date_year)
        {
            DateTime startDate = new DateTime(start_date_year, start_date_month, start_date_day);
            DateTime endDate   = new DateTime(end_date_year, end_date_month, end_date_day);

            List<Order> allOrders = orderRepository.AllIncluding(o => o.OrderDetail, o => o.Person, o => o.Statuses).Where(o => (o.Date >= startDate) && (o.Date <= endDate)).ToList();

            dynamic json_all_orders = new JsonArray();
            for (int i = 0; i < endDate.Subtract(startDate).Days; i++)
            {
                DateTime date= startDate.AddDays(i);
                dynamic day = new JsonObject();
                day.Date = date;
                day.possible_states = GetPosibleStatesForOrders(date); //new JsonArray();
                day.current_state = GetCurrentState(date);
                json_all_orders.Add(day);
            }
            return json_all_orders.ToString();
        }
开发者ID:duda92,项目名称:javascript,代码行数:19,代码来源:OrdersController.cs

示例7: Save_Tick

        /**
         * 退出
         */
        void Save_Tick(object sender, EventArgs e1)
        {
            //记录数据
            //传递到后台执行
            Uri uri = new Uri(WebClientInfo.BaseAddress);
            WebClient client = new WebClient();
            client.UploadStringCompleted += (o, e) =>
            {
                this.IsBusy = false;
                //通知数据提交过程完成
                if (e.Error != null)
                {
                    this.State = State.Error;
                    this.Error = e.Error.GetMessage();

                }
               
                this.OnCompleted(e);
            };
            JsonArray array = new JsonArray();
            JsonValue json = SaveToJson();
            if (json is JsonObject)
            {
                //把执行批处理对象的名字添加进去
                json["name"] = this.Name;
                array.Add(json);
            }
            else
            {
                array = (JsonArray)json;
            }
            this.IsBusy = true;
            this.State = State.Start;
            client.UploadStringAsync(uri, array.ToString());
        }
开发者ID:DuBin1988,项目名称:restv2,代码行数:38,代码来源:Phone.cs

示例8: ValidJsonArrayRoundTrip

        public void ValidJsonArrayRoundTrip()
        {
            bool oldValue = CreatorSettings.CreateDateTimeWithSubMilliseconds;
            CreatorSettings.CreateDateTimeWithSubMilliseconds = false;
            try
            {
                int seed = 1;
                Log.Info("Seed: {0}", seed);
                Random rndGen = new Random(seed);

                JsonArray sourceJson = new JsonArray(new JsonValue[]
                {
                    PrimitiveCreator.CreateInstanceOfBoolean(rndGen),
                    PrimitiveCreator.CreateInstanceOfByte(rndGen),
                    PrimitiveCreator.CreateInstanceOfDateTime(rndGen),
                    PrimitiveCreator.CreateInstanceOfDateTimeOffset(rndGen),
                    PrimitiveCreator.CreateInstanceOfDecimal(rndGen),
                    PrimitiveCreator.CreateInstanceOfDouble(rndGen),
                    PrimitiveCreator.CreateInstanceOfInt16(rndGen),
                    PrimitiveCreator.CreateInstanceOfInt32(rndGen),
                    PrimitiveCreator.CreateInstanceOfInt64(rndGen),
                    PrimitiveCreator.CreateInstanceOfSByte(rndGen),
                    PrimitiveCreator.CreateInstanceOfSingle(rndGen),
                    PrimitiveCreator.CreateInstanceOfString(rndGen),
                    PrimitiveCreator.CreateInstanceOfUInt16(rndGen),
                    PrimitiveCreator.CreateInstanceOfUInt32(rndGen),
                    PrimitiveCreator.CreateInstanceOfUInt64(rndGen)
                });

                JsonArray newJson = (JsonArray)JsonValue.Parse(sourceJson.ToString());

                Log.Info("Original JsonArray object is: {0}", sourceJson);
                Log.Info("Round-tripped JsonArray object is: {0}", newJson);

                if (!JsonValueVerifier.Compare(sourceJson, newJson))
                {
                    Assert.Fail("Test failed!  The new JsonValue does not equal to the original one.");
                }
            }
            finally
            {
                CreatorSettings.CreateDateTimeWithSubMilliseconds = oldValue;
            }
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:44,代码来源:JsonStringRoundTripTests.cs

示例9: GetOperationsJSONValue

        private string GetOperationsJSONValue(IEnumerable<AccountOperation> operations)
        {
            dynamic json = new JsonArray();

            foreach (var operation in operations)
            {
                dynamic operation_item = new JsonObject();
                operation_item.Date = operation.Date;
                operation_item.Amount = operation.Amount;
                operation_item.Summary = operation.Summary;
                if (operation is CreditOperation)
                    operation_item.OrderId = ((CreditOperation)operation).Order.Id;
                json.Add(operation_item);
            }
            return json.ToString();
        }
开发者ID:duda92,项目名称:DinnerAccounting,代码行数:16,代码来源:PeopleController.cs

示例10: Invoke

 //把函数转换出来的Json串交给后台数据库服务
 public void Invoke(IAsyncObject obj, Func<JsonValue> method)
 {
     //传递到后台执行
     Uri uri = new Uri(Uri);
     WebClient client = new WebClient();
     client.UploadStringCompleted += (o, e) =>
     {
         obj.IsBusy = false;
         //通知数据提交过程完成
         if (e.Error != null)
         {
             obj.State = State.Error;
             obj.Error = e.Error.GetMessage();
         }
         else
         {
             //返回数据重新赋值给对象
             JsonObject resultJson =  (JsonObject)JsonValue.Parse(e.Result);
             if (resultJson.ContainsKey(obj.Name))
             {
                 (obj as IFromJson).FromJson((JsonObject)resultJson[obj.Name]);
             }
             //判定是否保存成功
             if (resultJson.ContainsKey("success")) 
             {
                 string success = resultJson["success"];
                 MessageBox.Show(success);
             }
             if (resultJson.ContainsKey("error"))
             {
                 obj.Error = resultJson["error"];
                 obj.State = State.Error;
                 obj.OnCompleted(e);
                 return;
             }
             else 
             {
                 obj.State = State.End;
             }
         }
         obj.OnCompleted(e);
     };
     JsonArray array = new JsonArray();
     JsonValue json = method();
     if (json is JsonObject)
     {
         //把执行批处理对象的名字添加进去
         json["name"] = obj.Name;
         array.Add(json);
     }
     else
     {
         array = (JsonArray) json;
     }
     obj.IsBusy = true;
     obj.State = State.Start;
     client.UploadStringAsync(uri, array.ToString());
 }
开发者ID:DuBin1988,项目名称:restv2,代码行数:59,代码来源:DBService.cs

示例11: PostToWall

        public void PostToWall()
        {
            try
            {
                var actionLinks = new JsonArray();

                var learnMore = new JsonObject();
                learnMore.Add("text", "Learn more about Big Profile");
                learnMore.Add("href", "http://myapp.no/BigProfile");

                var appStore = new JsonObject();
                appStore.Add("text", "Visit App Store");
                appStore.Add("href", "http://myapp.no/BigProfileAppStore");

                //actionLinks.Add(learnMore);
                actionLinks.Add(appStore);

                var attachment = new JsonObject();
                attachment.Add("name", "Big Profile");
                attachment.Add("description", "Make your profile stand out with a big profile picture stretched across the new Facebook design. Available in App Store!");
                attachment.Add("href", "http://myapp.no/BigProfile");

                var parameters = new NSMutableDictionary();
                parameters.Add(new NSString("user_message_prompt"), new NSString("Tell your friends"));
                parameters.Add(new NSString("attachment"), new NSString(attachment.ToString()));
                parameters.Add(new NSString("action_links"), new NSString(actionLinks.ToString()));

                _facebook.Dialog("stream.publish", parameters, facebookDialogDelegate);
            }
            catch(Exception ex)
            {
                Console.WriteLine("Exception when showing dialog: {0}", ex);
            }
        }
开发者ID:follesoe,项目名称:FacebookBigProfile,代码行数:34,代码来源:FacebookController.cs

示例12: submitRpc

  /**
   * Collects all of the queued requests and encodes them into a single JSON
   * string before creating a new HTTP request, attaching this string to the
   * request body, signing it, and sending it to the container.
   * 
   * @param  client OpenSocialClient object with RPC_ENDPOINT property set
   * @return Object encapsulating the data requested from the container
   * @throws OpenSocialRequestException
   * @throws JSONException
   * @throws OAuthException
   * @throws IOException
   * @throws URISyntaxException
   */
  private OpenSocialResponse submitRpc(OpenSocialClient client)
  {

    String rpcEndpoint =
      client.getProperty(OpenSocialClient.Properties.RPC_ENDPOINT);

    JsonArray requestArray = new JsonArray();
    foreach(OpenSocialRequest r in this.requests) {
        requestArray.Put(JsonConvert.Import(r.getJsonEncoding()));
    }

    OpenSocialUrl requestUrl = new OpenSocialUrl(rpcEndpoint);

    OpenSocialHttpRequest request = new OpenSocialHttpRequest(requestUrl);
    request.setPostBody(requestArray.ToString());

    OpenSocialRequestSigner.signRequest(request, client);

    String responseString = getHttpResponse(request);
    return OpenSocialJsonParser.getResponse(responseString);
  }
开发者ID:s7loves,项目名称:pesta,代码行数:34,代码来源:OpenSocialBatch.cs

示例13: GetUser

 public string GetUser(string q)
 {
     DataTable table = new FBProject().GetUser(q).Tables[0];
     JsonArray jsonList = new JsonArray();
     Jayrock.Json.JsonObject json;
     foreach (DataRow row in table.Rows)
     {
         json = new Jayrock.Json.JsonObject();
         json.Accumulate("uname", row["username"]);
         //UserId
         jsonList.Add(json);
     }
     string str = jsonList.ToString();
     return str;
 }
开发者ID:jxb505,项目名称:FbCRM2,代码行数:15,代码来源:WebBll.cs

示例14: ToStringTest

 public void ToStringTest()
 {
     JsonObject jo = new JsonObject
     {
         { "first", 1 },
         { "second", 2 },
         { "third", new JsonObject { { "inner_one", 4 }, { "", null }, { "inner_3", "" } } },
         { "fourth", new JsonArray { "Item1", 2, false } },
         { "fifth", null }
     };
     JsonValue jv = new JsonArray(123, null, jo);
     string expectedJson = "[123,null,{\"first\":1,\"second\":2,\"third\":{\"inner_one\":4,\"\":null,\"inner_3\":\"\"},\"fourth\":[\"Item1\",2,false],\"fifth\":null}]";
     Assert.AreEqual(expectedJson, jv.ToString());
 }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:14,代码来源:JsonValueTest.cs

示例15: OrdersListByDateToJson

 private string OrdersListByDateToJson(List<Order> allOrders, DateTime date)
 {
     dynamic json_all_orders = new JsonArray();
     foreach (var order in allOrders)
           json_all_orders.Add(Order_(order));
     return json_all_orders.ToString();
 }
开发者ID:duda92,项目名称:javascript,代码行数:7,代码来源:OrdersController.cs


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