Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Lab8
- {
- public class Friend
- {
- public int id { get; set; }
- public string name { get; set; }
- }
- public class Person
- {
- public string _id { get; set; }
- public int index { get; set; }
- public string guid { get; set; }
- public bool isActive { get; set; }
- public string balance { get; set; }
- public string picture { get; set; }
- public int age { get; set; }
- public string eyeColor { get; set; }
- public string name { get; set; }
- public string gender { get; set; }
- public string company { get; set; }
- public string email { get; set; }
- public string phone { get; set; }
- public string address { get; set; }
- public string about { get; set; }
- public string registered { get; set; }
- public double latitude { get; set; }
- public double longitude { get; set; }
- public List<string> tags = new List<string>();
- public List<Friend> friends = new List<Friend>();
- public string greeting { get; set; }
- public string favoriteFruit { get; set; }
- class Program
- {
- interface IInterface
- {
- }
- static void Main(string[] args)
- {
- var json = File.ReadAllText("generated.json");
- var JsonArray = JArray.Parse(json);
- //var people = JsonArray.Select(x => new Person {
- //// _id = (string)x["_id"],
- //// age = (int)x["age"],
- //// tags = x["tags"].ToObject<List<string>>(),
- //// friends=x["friends"].ToObject<List<Friend>> ()
- ////}).ToList();
- var people = JsonArray.ToObject<List<Person>>();
- var peple = JsonConvert.DeserializeObject<List<Person>>(json);
- foreach (var person in people)
- {
- Console.WriteLine(person._id+" "+person.age);
- Console.WriteLine( "tags" );
- foreach (var item in person.tags)
- {
- Console.WriteLine("\t"+item);
- }
- foreach (var item in person.friends)
- {
- Console.WriteLine("\t"+item.name);
- }
- }
- Func<double> f1;//nie ma parametrów zwraca double
- Func<double,double> f2;//1 parametr double
- f2 = x => x * x;
- Action p1;//()=>void
- Action<double> p2;//(double)->void
- p2 = x => Console.WriteLine(x);
- p2(34);
- Console.WriteLine(f2(25));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement