public class Equipment
{
public string Name { get; set; }
public string OldName{ get; set; }
}
public void Readjson(List <Equipment> equipments)
{
string jsonfile = @"C:\Users\test\Result.json";
StreamReader reader = File.OpenText(jsonfile);
JsonTextReader jsonTextReader = new JsonTextReader(reader);
JArray array = (JArray)JToken.ReadFrom(jsonTextReader);
foreach (JToken obj in array)
{
Equipment equipment = new Equipment();
equipment.Name = obj["Name "].ToString();
equipment.OldName= obj["OldName"].ToString();
equipments.Add(equipment);
}
reader.Close();
}
public static void Main(string[] args)
{
List<Equipment> equipments=new List<Equipment>();
Readjson(equipments);
}
[
{
"OldName": "123",
"Name ": "111",
}
]
|