简体   繁体   English

如何从 reactJS 或 C# 中的 JSON 获取自动生成的 ID

[英]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.

相关问题 如何获取自动生成的ID? - How do I get the auto generated Id? 使用官方C#驱动程序插入后,如何从mongo中读出自动生成的ID? - how to read back out the auto generated ID from mongo after insertion using official c# driver? 当 JSON 包含由 Json.Net C# 生成的 $ref 和 $id 时,如何在 Java 中反序列化它 - How can JSON be deserialized in Java when it contains $ref and $id generated by Json.Net C# ElasticSearch-如何从插入查询中获取自动生成的ID - ElasticSearch - how to get the auto generated id from an insert query 如何使用 C# 和 MongoDb 获取自动增量可预测 ID - How can I get autoincrement Predictable ID with C# and MongoDb 如何在C#中的dotnetrdf librery中获取blankNode ID - How can I get blankNode ID in dotnetrdf librery in C# 如何从用C#填充SQL数据的组合框中获取ID? - How can I get the ID from an combobox filled with SQL data in C#? 我如何从MVC下拉列表中获取选定的值作为C#中的操作链接ID - How can I get selected value from mvc dropdown list as action link id in c# 如何从进程名称中获取进程 ID? (C#) - How can I get process Id from process name? (C#) 我怎样才能从datagridview中的选定行获得整个对象而不显示对象ID -c# - how i can get the whole objected from the selected row in datagridview without displaying the object ID -c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM