我有
之类的json数据 <transition name="fade" mode="out-in" >
<ul v-if="showProducts">
<li class="bouncein" v-for="(menu, index) in todos" ...>
</ul>
</transition>
如何使用C#将其反序列化。
答案 0 :(得分:0)
下面显示了一种考虑的方法。关键是使用StudentDetails
类来定义您的个别学生的必要属性(以及Dictionary
-以便用字符串(例如“ John”)作为键)。 / p>
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Sample
{
public class StudentDetails
{
public string StudentName { get; set; }
public string RegistrationNo { get; set; }
public string Grade { get; set; }
}
class Program
{
static void Main(string[] args)
{
var input = @"{ ""John"": { ""StudentName"": ""John anow"", ""RegistrationNo"": ""xxxxx"", ""Grade"":""B""},
""Methwe 0"": { ""StudentName"": ""Methew"", ""RegistrationNo"": ""xxxxx"", ""Grade"":""B""},
""Johnsan 09"": { ""StudentName"": ""Johnsan anow"", ""RegistrationNo"": ""xxxxx"", ""Grade"":""B""}
}";
var output = JsonConvert.DeserializeObject<Dictionary<string, StudentDetails>>(input);
Console.ReadLine();
}
}
}