Dictionary<string, object> suggestions = JSONSerializer.Deserialize<Dictionary<string, object>>(jsonStudent)
if (suggestions.Keys.Contains("UserId"))
{
student["new_mduserid"] = suggestions["UserId"].ToString();//MD用户Id
}
多数组的可以用 List<Dictionary<string, object>>
try {
string json = File.ReadAllText("robotv1.json");
// 解析json文件
dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
Console.WriteLine(jsonObj.Lidar.DefaultBaud);
// 也可以修改
jsonObj.Lidar.DefaultBaud = 123;
//重修序列化
string output = Newtonsoft.Json.JsonConvert.SerializeObject(jsonObj, Newtonsoft.Json.Formatting.Indented);
//保存
File.WriteAllText("config.json", output);
}catch {