gpt4 book ai didi

c# - Newton.JSON 将动态对象转换为 JObject 而不是动态对象

转载 作者:行者123 更新时间:2023-11-30 22:18:24 25 4
gpt4 key购买 nike

string  result ="{"AppointmentID":463236,"Message":"Successfully Appointment Booked","Success":true,"MessageCode":200,"isError":false,"Exception":null,"ReturnedValue":null}"

dynamic d = JsonConvert.DeserializeObject<dynamic>(result);

d.GetType()是Newtonsoft.Json.Linq.JObject

那么如何将它反序列化为动态对象而不是 JObject

最佳答案

不太清楚什么对您不起作用以及您为什么关心返回类型,但您可以像这样直接访问反序列化对象的属性:

string result = @"{""AppointmentID"":463236,""Message"":""Successfully Appointment Booked"",""Success"":true,""MessageCode"":200,""isError"":false,""Exception"":null,""ReturnedValue"":null}";
dynamic d = JsonConvert.DeserializeObject<dynamic>(result);

string message = d.Message;
int code = d.MessageCode;
...

关于c# - Newton.JSON 将动态对象转换为 JObject 而不是动态对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16108093/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com