I used this solution to deserialize my JSON string. I am trying to avoid third-party libraries if at all possible.
However, the string of JSON I'm working with is structured like so:
{"BatchId":"32","BatchPriority":"NORMAL","Entries":{"Entry":
[{"EntryId":"185","EntryPriority":"HIGH","Value":"0.0"},
{"EntryId":"172","EntryPriority":"LOW","Value":"122.0"}]
}}
I am able to deseralize my JSON to set the BatchId
and BatchPriority
to the Batch
object (see below). However, I am unable to set the array of "Entries" from the JSON, whose value appears to be a JSON string itself.
How do I structure my object such that I am able to deseralize and set the array of "Entries" to the Batch
object just I am able to set values for the BatchId
and BatchPriority
properties? I know public Array Entries { get; set; }
is wrong but I am not sure how to approach this.
Batch
object:
public class Batch
{
public int BatchId { get; set; }
public string BatchPriority { get; set; }
public Array Entries { get; set; } //wrong
}
Entry
object:
public class Entry
{
public int EntryId { get; set; }
public string EntryPriority { get; set; }
public double Value { get; set; }
}