I'm having troubles to desirialize a JSON string to n object using JSON.net
I've tried the following but results are always null:
class auctionList
{
public auctionInfo auctionInfo { get; set; }
}
class auctionInfo
{
public IList<auction> auctions { get; set; }
}
class auction
{
public string tradeId { get; set; }
}
Here is the json string:
{
"auctionInfo": [
{
"tradeId": 276649263881
},
{
"tradeId": 356444585498
},
.......
]
}
auctionList auctions = JsonConvert.DeserializeObject<auctionList>(json);
auctions
is always null.
and is DeserializeObject the fastest way to do it if I just wanna reach 'tradeId'?
Any ideas? Thanks.
You need modify your string to:
{
"auctionInfo": { "auctions":
[
{
"tradeId": 276649263881
},
{
"tradeId": 356444585498
}
]
}
}
or set your classes to:
public class auction
{
public Auctioninfo[] auctionInfo { get; set; }
}
public class Auctioninfo
{
public string tradeId { get; set; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.