using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
public string id { get; set; }
public string title { get; set; }
public string content { get; set; }
public long creationTime { get; set; }
public long dueDate { get; set; }
public string status { get; set; }
public string type { get; set; }
public static async Task Test()
string _jsonFile = "Question71457255.json";
await File.WriteAllTextAsync(_jsonFile, GetJson());
string id = "11111111-1111-1111-2222-48af79af26d8";
using (StreamReader streamReader = new StreamReader(_jsonFile))
jArray = JArray.Parse(await streamReader.ReadToEndAsync());
JToken token = jArray.Children().FirstOrDefault(jToken =>
string jTokenId = jToken["id"].ToObject<string>();
return jTokenId.Equals(id);
if (token is null) return;
Todo todo = token.ToObject<Todo>();
todo.status = "the status was successfully updated";
jArray.Add(JsonConvert.SerializeObject(todo));
var q = JsonConvert.SerializeObject(jArray, Formatting.Indented);
if (jArray == default) return;
await File.WriteAllTextAsync(_jsonFile, q);
Console.WriteLine(await File.ReadAllTextAsync(_jsonFile));
""id"": ""6f4c1ba5-7927-478b-bf43-48af79af56d8"",
""title"": ""EuroJackpot awaiting Draw Result"",
""content"": ""draw 23232 awaiting draw result"",
""creationTime"": 1622375111971,
""dueDate"": 1622375125381,
""id"": ""11111111-1111-1111-2222-48af79af26d8"",
""title"": ""The entry I am trying to update"",
""content"": ""some content"",
""creationTime"": 1622375111971,
""dueDate"": 1622375125381,
public static async Task Main()
Console.WriteLine("Environment version: " + Environment.Version);
Console.WriteLine("{0} version: {1}", typeof(JsonSerializer).Namespace, typeof(JsonSerializer).Assembly.FullName);
Console.WriteLine("Failed with unhandled exception: ");