[英]How can i get auto generated id from JSON in reactJS or C#
how can i get auto generated id from this object in an array thank you我如何从数组中的这个 object 获取自动生成的 ID 谢谢
{
"CourseList": {
"-Lti4CFDdJwAkBW5ujqm": { //auto generated id
"a1_courseName": "robotics",
"a2_courseCode": "1212"
},
"-LtrpJSDN4OCQAyJiSmQ": { //auto generated id
"a1_courseName": "shsh",
"a2_courseCode": "hhshs"
}
},
"PersonalInfo": {
"email": "arifulis@******.edu",
"teacherInstitute": "####",
"teacherName": "arif"
}
}
I have tested with NewtonSoft Json , generate it as Dictionary,我已经用NewtonSoft Json进行了测试,将其生成为字典,
public partial class CourseAndnfo
{
public Dictionary<string, CourseList> CourseList { get; set; }
public PersonalInfo PersonalInfo { get; set; }
}
public partial class CourseList
{
public string a1_courseName { get; set; }
public string a2_courseCode { get; set; }
}
public partial class PersonalInfo
{
public string Email { get; set; }
public string TeacherInstitute { get; set; }
public string TeacherName { get; set; }
}
Deserialize it using,使用反序列化它,
var ParsedJson = JsonConvert.DeserializeObject<CourseAndInfo>(Yourjson);
List<string> AutoGeneratedIds = ParsedJson.CourseList.Keys.ToList();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.