Exemple #1
0
        static void sample1MusicTrack()
        {
            MusickTrack m    = new MusickTrack(artist: "Anibal Martinez", title: "Me pecho sobre tu espalda.", lenght: 100);
            string      json = JsonConvert.SerializeObject(m);

            Console.WriteLine("JSON");
            Console.WriteLine(json);

            MusickTrack mD = JsonConvert.DeserializeObject <MusickTrack>(json);

            Console.WriteLine("Deserialize");
            Console.WriteLine(m.ToString());

            Console.ReadKey();
        }
Exemple #2
0
        static void sample2ListAlbumMusic()
        {
            List <MusickTrack> album = new List <MusickTrack>();

            string[] trackNames = new string[] { "My Way", "Your Way", "Their Way", "The Wrong Way" };
            foreach (string trackName in trackNames)
            {
                MusickTrack m = new MusickTrack(artist: "Rob Miles", trackName, lenght: 150);
                album.Add(m);
            }

            Console.WriteLine("JSON");
            string jsonAlbum = JsonConvert.SerializeObject(album);

            Console.WriteLine(jsonAlbum);
            List <MusickTrack> lsD = JsonConvert.DeserializeObject <List <MusickTrack> >(jsonAlbum);

            foreach (MusickTrack m in lsD)
            {
                Console.WriteLine(m.ToString());
            }

            Console.ReadKey();
        }