本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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);
}