コード例 #1
0
        static void Main(string[] args)
        {
            var    path = Path.Combine(Environment.CurrentDirectory, "json.txt");
            string json = File.ReadAllText(path);

            Models.Currency currency = Newtonsoft.Json.JsonConvert.DeserializeObject <Models.Currency>(json);

            write(currency.ToFormatedString());

            var jsonOut = Newtonsoft.Json.JsonConvert.SerializeObject(currency);
            var pathOut = Path.Combine(Environment.CurrentDirectory, "jsonOut.txt");

            File.WriteAllText(pathOut, jsonOut);

            Console.WriteLine("Нажмите кнопку");
            Console.ReadKey();
        }
コード例 #2
0
ファイル: Extensions.cs プロジェクト: Inag0/LearnTogether
 public static string ToFormatedString(this Models.Currency currency)
 {
     return(string.Format("Id: {0}\nDate:{1}\nValue:{2}\nRatio: {3}", currency.CurrencyId, currency.Date, currency.Value, currency.Ratio));
 }