Ad
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
{
"CourseList": {
"-Lti4CFDdJwAkBW5ujqm": { //auto generated id
"a1_courseName": "robotics",
"a2_courseCode": "1212"
},
"-LtrpJSDN4OCQAyJiSmQ": { //auto generated id
"a1_courseName": "shsh",
"a2_courseCode": "hhshs"
}
},
"PersonalInfo": {
"email": "[email protected]******.edu",
"teacherInstitute": "####",
"teacherName": "arif"
}
}
Ad
Answer
I have tested with NewtonSoft Json, generate it as Dictionary,
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();
Ad
source: stackoverflow.com
Related Questions
- → How to Fire Resize event after all images resize
- → JavaScript in MVC 5 not being read?
- → URL routing requires /Home/Page?page=1 instead of /Home/Page/1
- → Getting right encoding from HTTPContext
- → How to create a site map using DNN and C#
- → I want integrate shopify into my mvc 4 c# application
- → Bootstrap Nav Collapse via Data Attributes Not Working
- → Shopify api updating variants returned error
- → Get last n quarters in JavaScript
- → ASP.NET C# SEO for each product on detail page on my ECOMMERCE site
- → SEO Meta Tags From Behind Code - C#
- → onchange display GridView record if exist from database using Javascript
- → How to implement search with two terms for a collection?
Ad