fork download
  1. using Newtonsoft.Json;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApp1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. var taro = new Test() { count = 2, page = 1 };
  11. var io = new Test.Person() { name = "Io", age = 17 };
  12. var p = new Test.Person() { name = "P", age = 10 };
  13. taro.status= new List<Test.Person>() { io, p };
  14.  
  15. var json = JsonConvert.SerializeObject(taro);
  16. var taro_reversed = JsonConvert.DeserializeObject<Test>(json);
  17. }
  18. }
  19.  
  20. public class Test
  21. {
  22. public int count { get; set; }
  23.  
  24. public int page { get; set; }
  25.  
  26. public List<Person> status { get; set; }
  27.  
  28. public class Person
  29. {
  30. public string name { get; set; }
  31.  
  32. public int age { get; set; }
  33. }
  34. }
  35. }
  36.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,7): error CS0246: The type or namespace name `Newtonsoft' could not be found. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings
stdout
Standard output is empty