public IActionResult getNoteContent(string noteId) { string a = System.IO.File.ReadAllText("TextFile.txt"); var options = new System.Text.Json.JsonSerializerOptions { Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping }; //NoteContent noteContent1 = JsonSerializer.Deserialize<NoteContent>(a, options); //NoteService.InsertNoteContent(noteContent1); NoteContent noteContent = NoteContentService.SelectNoteContent(123123); string json = JsonSerializer.Serialize(noteContent, options); // return Content(a); return(Content(json)); }
public void GetNoteContentTest() { string a = System.IO.File.ReadAllText(@"E:\github\MoreNote\MoreNote\TextFile.txt"); NoteContent noteContent = NoteContentService.SelectNoteContent(123123); string json = JsonSerializer.Serialize(noteContent, MyJsonConvert.GetOptions()); NoteContent noteContent2 = JsonSerializer.Deserialize <NoteContent>(json, MyJsonConvert.GetOptions()); Console.WriteLine(noteContent2.UserId); Console.WriteLine(noteContent2.NoteId); Console.WriteLine(noteContent2.UpdatedUserId); //Console.WriteLine(noteContent2.Content); //string json=JsonConvert.SerializeObject(noteContent); //Console.WriteLine(json); // Assert.Fail(); }