Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6843957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:19:01+00:00 2026-05-27T00:19:01+00:00

I’m trying to use JSON.Net to deserialize a JSON object into a C# object.

  • 0

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 Type, which contains a list of Categories, which in turn contains a list of Funds. They are defined as:

public class MonthlyPerformance
{
    public List<Type> Types { get; set; }
}

public class Type
{
    public int Id { get; set; }
    public string CountryId { get; set; }
    public string Name { get; set; }

    public List<Category> Categories { get; set; }

    public Type()
    {

    }
}

public class Category
{
    public int Id { get; set; }
    public string CountryId { get; set; }
    public string Name { get; set; }

    public List<ConfigurationFund> Funds { get; set; }

    public Category()
    {

    }
}

public class Fund
{
    public int Id { get; set; }
    public string CountryId { get; set; }
    public string Name { get; set; }

    public Fund()
    {

    }
}

I thought the following would do it, but it’s not. It’s just creating an instance of the Type object with everything null:

var file = File.ReadAllText(filePath);

var types = JsonConvert.DeserializeObject<Type>(file);

This is the JSON that I’m using:

{
  "MonthlyPerformance": {
    "Type": [
      {
        "id": "65",
        "countryId": "IE",
        "name": "Irish Domestic Funds (Gross)",
        "Category": [
          {
            "id": "25003334",
            "countryId": "IE",
            "name": "UK Equity",
            "ConfigurationFund": [
              {
                "id": "25000301",
                "countryId": "IE",
                "name": "Aviva Irl UK Equity Fund"
              },
              {
                "id": "25000349",
                "countryId": "IE",
                "name": "New Ireland UK Equity 9"
              }
            ]
          },
          {
            "id": "25003339",
            "countryId": "IE",
            "name": "Irish Equity",
            "Fund": [
              {
                "id": "25000279",
                "countryId": "IE",
                "name": "Friends First Irish Equity G"
              },
              {
                "id": "25000305",
                "countryId": "IE",
                "name": "Irish Life Celticscope 2 G"
              }
            ]
          }
        ]
      },
      {
        "id": "80",
        "countryId": "IE",
        "name": "Irish Individual Pensions",
        "Category": [
          {
            "id": "25003347",
            "countryId": "IE",
            "name": "Asia Pacific Ex-Japan Equity",
            "Fund": [
              {
                "id": "25001789",
                "countryId": "IE",
                "name": "Aviva Irl Pacific Basin Eq"
              },
              {
                "id": "25002260",
                "countryId": "IE",
                "name": "Ir Life Pacific Eq Indexed  P"
              }
            ]
          },
          {
            "id": "25003365",
            "countryId": "IE",
            "name": "Flexible Equity",
            "Fund": [
              {
                "id": "25003238",
                "countryId": "IE",
                "name": "Friends First Protected Equity Plus Fund S2"
              },
              {
                "id": "25003267",
                "countryId": "IE",
                "name": "Friends First Protected Equity Plus Bond G"
              }
            ]
          }
        ]
      }
    ]
  }
}

What do I need to do to get this to work?

edited to include MonthlyPerformance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:19:01+00:00Added an answer on May 27, 2026 at 12:19 am

    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" 
            } 
        ] 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.