Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. class Program {
  8.  
  9.     static void Main (string[] args) {
  10.         string json = @"{
  11.            'Name': 'Bad Boys',
  12.            'ReleaseDate': '1995-4-7T00:00:00',
  13.            'Genres': [
  14.            'Action',
  15.            'Comedy'
  16.            ]}";
  17.  
  18.         Movie m = JsonConvert.DeserializeObject<Movie>(json);
  19.  
  20.         string name = m.Name;
  21.         string releaseDate = m.ReleaseDate;
  22.         string[] genres = m.Genres;
  23.  
  24.         string x = Console.ReadLine();
  25.        
  26.         if(genres.Contains(x)) {
  27.             Console.WriteLine(m.Name + " is a " + x + " movie");
  28.         }
  29.  
  30.         Console.WriteLine("\n" + name + "\n" + releaseDate);
  31.         Console.ReadLine();
  32.  
  33.         //Action
  34.         //Comedy
  35.  
  36.         //Bad Boys
  37.         //1995 - 4 - 7T00: 00:00
  38.     }
  39. }
  40.  
  41. public class Movie {
  42.     public string ReleaseDate { get; set; }
  43.     public string Name { get; set; }
  44.     public string[] Genres { get; set; }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement