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


C# JSONObject.getString方法代码示例

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


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

示例1: fromJson

        public static CustomField fromJson(JSONObject obj) {
            CustomField field = new CustomField();

            field.id = obj.getString("id");
            field.name = obj.getString("name");
            field.type = obj.getString("type");
            field.options = obj.getString("seloptions");

            return field;
        }
开发者ID:prestanneth,项目名称:UpviseSDK,代码行数:10,代码来源:CustomField.cs

示例2: dispJsonObject

    private void dispJsonObject(JSONObject jsonObj)
    {
        text("-- Object: jsonObj.json", x, y); y += 40;

        int id = jsonObj.getInt("id");
        string species = jsonObj.getString("species");
        string name = jsonObj.getString("name");

        string info = id + ", " + species + ", " + name;
        text(info, x, y); y += 40;
        println(info);

        y += 40;
    }
开发者ID:nryota,项目名称:uProcessing,代码行数:14,代码来源:JsonData.cs

示例3: run

        public void run() {
            try {
                // Login
                string token = Query.login("[email protected]", "demobiz");
                Console.WriteLine("Login OK");

                // Create an instance of hte query class
                Query query = new Query(token);

                // Select all open tasks from the "Tasks.tasks" table 
                // You can go to your Upvise web account in the Task app and create some tasks first
                JSONObject where = new JSONObject();
                where.put("status", 0);
                JSONObject[] tasks = query.select("Tasks.tasks", where);
                Console.WriteLine("Found " + tasks.Length + " open tasks in this database");
                foreach (JSONObject task in tasks) {
                    Console.WriteLine("Task ID: " + task.getString("id"));
                    Console.WriteLine("Name: " + task.getString("name"));
                    Console.WriteLine("Due Date: " + task.getDate("duedate"));
                    Console.WriteLine("Owner: " + task.getString("owner"));
                    Console.WriteLine("Status:" + task.getInt("status"));
                }

                // Create a bunch of tasks using Batch operation
                Console.WriteLine("Creating 10 new tasks...");
                query.beginBatch();
                for (int i = 0; i < 10; i ++) {
                    JSONObject task = new JSONObject();
                    task.put("id", "TASKID_" + i);
                    task.put("name", "My Task " + i);
                    task.put("owner", "John");
                    task.put("status", 0);
                    task.putDate("duedate", DateTime.Now.AddDays(2));

                    query.insert("Tasks.tasks", task);
                }
                query.commitBatch();
                
                // update All open John's Tasks and mark them complete (status=1)
                where.put("owner", "John");
                where.put("status", 0);
                JSONObject[] myTasks = query.select("Tasks.tasks", where);
                Console.WriteLine("found " + myTasks.Length  + " open tasks for John");
                // Start a new batch operation to group all updates into one HTTPS request for best performance
                query.beginBatch();
                foreach(JSONObject task in myTasks) {
                    string id = task.getString("id");
                    JSONObject values = new JSONObject();
                    values.putDate("duedate", DateTime.Now);
                    values.put("status", 1);
                    query.updateId("Tasks.tasks", id, values);
                }
                query.commitBatch();
                Console.WriteLine("Updated the tasks to Complete");

                // Now Get All John's completed Tasks, export them in a file and delete them
                where.put("owner", "John");
                where.put("status", 1);
                JSONObject[] completedTasks = query.select("Tasks.tasks", where);
                Console.WriteLine("found " + completedTasks.Length + " completed tasks for John");

                StringBuilder buffer = new StringBuilder();
                // Start a new batch operation
                query.beginBatch();
                foreach (JSONObject task in completedTasks) {
                    string id = task.getString("id");
                    // Add the task data in the buffer
                    buffer.AppendLine(task.ToString());
                    query.deleteId("Tasks.tasks", id);

                }
                query.commitBatch();
                Console.WriteLine("Deleted completed tasks for John");
                // Save the file to disk
                System.IO.File.WriteAllText(@"C:\\temp\completedTasks.txt", buffer.ToString());
                
            } catch (Exception e) {
                Console.WriteLine("Error:" + e.Message);
            }
        }
开发者ID:prestanneth,项目名称:UpviseSDK,代码行数:80,代码来源:TaskSample.cs

示例4: notificationOpened

		  /// <summary>
		  /// Called when a notification is opened from the Android status bar or a new one comes in while the app is in focus.
		  /// </summary>
		  /// <param name="message">
		  ///           The message string the user seen/should see in the Android status bar. </param>
		  /// <param name="additionalData">
		  ///           The additionalData key value pair section you entered in on onesignal.com. </param>
		  /// <param name="isActive">
		  ///           Was the app in the foreground when the notification was received. </param>
		  public override void notificationOpened(string message, JSONObject additionalData, bool isActive)
		  {
			 string messageTitle = "OneSignal Example", messageBody = message;

			 try
			 {
				if (additionalData != null)
				{
				   if (additionalData.has("title"))
				   {
					  messageTitle = additionalData.getString("title");
				   }
				   if (additionalData.has("actionSelected"))
				   {
					  messageBody += "\nPressed ButtonID: " + additionalData.getString("actionSelected");
				   }

				   messageBody = message + "\n\nFull additionalData:\n" + additionalData.ToString();
				}
			 }
			 catch (JSONException)
			 {
			 }

			 SafeAlertDialog(messageTitle, messageBody);
		  }
开发者ID:moljac,项目名称:Samples.Data.Porting,代码行数:35,代码来源:MainActivity.cs


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