[
{
"Год/Месяц": "2017",
"Январь": "1,2,3,4,5,6,7,8,14,15,21,22,28,29",
"Февраль": "4,5,11,12,18,19,22*,23,24,25,26",
"Март": "4,5,7*,8,11,12,18,19,25,26",
"Апрель": "1,2,8,9,15,16,22,23,29,30",
"Май": "1,6,7,8,9,13,14,20,21,27,28",
"Июнь": "3,4,10,11,12,17,18,24,25",
"Июль": "1,2,8,9,15,16,22,23,29,30",
"Август": "5,6,12,13,19,20,26,27",
"Сентябрь": "2,3,9,10,16,17,23,24,30",
"Октябрь": "1,7,8,14,15,21,22,28,29",
"Ноябрь": "3*,4,5,6,11,12,18,19,25,26",
"Декабрь": "2,3,9,10,16,17,23,24,30,31"
}
]
public class Calendar
{
[JsonProperty(PropertyName = "Год/Месяц")]
public string year { get; set; }
[JsonProperty(PropertyName = "Январь")]
public string january { get; set; }
[JsonProperty(PropertyName = "Февраль")]
public string february { get; set; }
//и т.д.
}
List<Calendar> calendar = JsonConvert.DeserializeObject<List<Calendar>>(json);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using System.IO;
using System.Net;
using System.Runtime.Serialization;
using Newtonsoft.Json.Linq;
namespace load_calendar
{
class Program
{
static void Main(string[] args)
{
string json = File.ReadAllText("calendar.json");
List<Calendar2> calendar = JsonConvert.DeserializeObject<List<Calendar2>>(json);
Console.WriteLine("Февраль:");
foreach (Calendar2 r in calendar)
{
for (int i = 0; i < r.february.Length; i++)
{
Console.WriteLine(r.february[i]);
}
}
Console.ReadKey();
}
public class Calendar2
{
[JsonProperty(PropertyName = "Год/Месяц")]
public string year { get; set; }
public string[] january { get; set; }
public string[] february { get; set; }
//и т.д.
[JsonExtensionData]
private IDictionary<string, JToken> _additionalData;
[OnDeserialized]
private void OnDeserialized(StreamingContext context)
{
string _jan = (string)_additionalData["Январь"];
january = _jan.Split(',');
string _feb = (string)_additionalData["Февраль"];
february = _feb.Split(',');
//и т.д.
}
public Calendar2()
{
_additionalData = new Dictionary<string, JToken>();
}
}
}
}
Февраль:
4,
5,
11,
12,
18,
19,
22*,
23,
24,
25,
26