I\'m trying to use JSON.Net to deserialize a JSON object into a C# object.
The object I want to create is MonthlyPerformance
which contains a list of
I believe the problem is in your Json string.
"Type": [ ... ]
Should be
"Types": [ ... ]
Types
is the name of property that should be deserialized, you mistakenly put Type
the class name instead.
The same goes for Categories
property in the Type
class.
Also I simply removed "MonthlyPerformance"
root from the Json string and it worked like a charm. With Json.NET of course.
Here is a snippets of the modified Json with appropriate property names (notice, Types, Categories, Funds and the absence of MonthlyPerformance root)
{
"Types": [
{
"id": "65",
"countryId": "IE",
"name": "Irish Domestic Funds (Gross)",
"Categories": [
{
"id": "25003334",
"countryId": "IE",
"name": "UK Equity",
"Funds": [
{
"id": "25000301",
"countryId": "IE",
"name": "Aviva Irl UK Equity Fund"
},
{
"id": "25000349",
"countryId": "IE",
"name": "New Ireland UK Equity 9"
}
]
}