2 回答
TA贡献1799条经验 获得超8个赞
你的类对于这个对象是错误的
public class JsonClass
{
public RoomClass room1 {get; set;}
public RoomClass room2 {get; set;}
}
public class RoomClass
{
[JsonProperty("first")]
public string first { get; set; }
[JsonProperty("second")]
public string second { get; set; }
[JsonProperty("third")]
public string third { get; set; }
}
然后
var result = JsonConvert.DeserializeObject<JsonClass>(jsonstring);
编辑:OP表示会有很多房间
var result = JsonConvert.DeserializeObject<IDictionary<string, RoomClass>>(jsonstring);
TA贡献1853条经验 获得超9个赞
public class Rooms
{
public Streams room1{ get; set; }
public Streams room2{ get; set; }
}
Rooms r = JsonConvert.DeserializeObject<Rooms>(jsonstring);
- 2 回答
- 0 关注
- 271 浏览
添加回答
举报