Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9.  
  10. namespace Lab8
  11. {
  12.  
  13. public class Friend
  14. {
  15. public int id { get; set; }
  16. public string name { get; set; }
  17. }
  18.  
  19. public class Person
  20. {
  21. public string _id { get; set; }
  22. public int index { get; set; }
  23. public string guid { get; set; }
  24. public bool isActive { get; set; }
  25. public string balance { get; set; }
  26. public string picture { get; set; }
  27. public int age { get; set; }
  28. public string eyeColor { get; set; }
  29. public string name { get; set; }
  30. public string gender { get; set; }
  31. public string company { get; set; }
  32. public string email { get; set; }
  33. public string phone { get; set; }
  34. public string address { get; set; }
  35. public string about { get; set; }
  36. public string registered { get; set; }
  37.  
  38. public double latitude { get; set; }
  39. public double longitude { get; set; }
  40. public List<string> tags = new List<string>();
  41. public List<Friend> friends = new List<Friend>();
  42. public string greeting { get; set; }
  43. public string favoriteFruit { get; set; }
  44. class Program
  45. {
  46. interface IInterface
  47. {
  48.  
  49. }
  50. static void Main(string[] args)
  51. {
  52. var json = File.ReadAllText("generated.json");
  53. var JsonArray = JArray.Parse(json);
  54. //var people = JsonArray.Select(x => new Person {
  55. //// _id = (string)x["_id"],
  56. //// age = (int)x["age"],
  57. //// tags = x["tags"].ToObject<List<string>>(),
  58. //// friends=x["friends"].ToObject<List<Friend>> ()
  59.  
  60. ////}).ToList();
  61. var people = JsonArray.ToObject<List<Person>>();
  62. var peple = JsonConvert.DeserializeObject<List<Person>>(json);
  63. foreach (var person in people)
  64. {
  65. Console.WriteLine(person._id+" "+person.age);
  66. Console.WriteLine( "tags" );
  67.  
  68. foreach (var item in person.tags)
  69. {
  70. Console.WriteLine("\t"+item);
  71.  
  72. }
  73.  
  74. foreach (var item in person.friends)
  75. {
  76. Console.WriteLine("\t"+item.name);
  77.  
  78. }
  79. }
  80.  
  81. Func<double> f1;//nie ma parametrów zwraca double
  82. Func<double,double> f2;//1 parametr double
  83. f2 = x => x * x;
  84. Action p1;//()=>void
  85. Action<double> p2;//(double)->void
  86. p2 = x => Console.WriteLine(x);
  87. p2(34);
  88. Console.WriteLine(f2(25));
  89. }
  90.  
  91.  
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement