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 6208563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:49:47+00:00 2026-05-24T05:49:47+00:00

Before I get flagged for duplicate, I have the code from Dynamic json object

  • 0

Before I get flagged for duplicate, I have the code from Dynamic json object with numerical keys working quite well now. The question with my numeric keys is that unfortunately, the JSON string I am getting is initially delimited by year, so would I use reflection to attempt to create a dynamic property on a dynamic object, and if so how? I know with a dynamic object I can’t have obj[“2010”] or obj[0]. In JavaScript this is no problem, just trying to get it working in C#. Ideas?
Example of JSON being returned:

    {
"2010": [
    {
        "type": "vacation",
        "alloc": "90.00"
    },

Alternatively, sometimes the year is the second element as such:
I have no control over this json.

    {
"year": [],
"2010": [
    {
        "type": "vacation",
        "alloc": "0.00"
    },
  • 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-24T05:49:49+00:00Added an answer on May 24, 2026 at 5:49 am

    Maybe I’m misunderstanding your question, but here’s how I’d do it:

    static void Main(string[] args) {
    
    var json = @"
    {
      '2010': [
      {
        'type': 'vacation',
        'alloc': '90.00'
      },
      {
        'type': 'something',
        'alloc': '80.00'
      }
    ]}";
    
    
    var jss = new JavaScriptSerializer();
    var obj = jss.Deserialize<dynamic>(json);
    
    Console.WriteLine(obj["2010"][0]["type"]);
    
    Console.Read();
    
    }
    

    Does this help?

    I wrote a blog post on serializing/deserializing JSON with .NET: Quick JSON Serialization/Deserialization in C#

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm thinking of re-working my MVC before I get to far along with it.
A little disclaimer before I get ridiculed for not putting up code examples: I
We have just started our new assignment - web-based project. Before I get directly
I have a class which exposes literally dozens of events(before you get of on
I'm new to Cocoa and have a small question before I get carried away
I want to check if a resource key exists before get it from resources.
Background Story A little back story before i get to the question. I'm working
Before I get into the details of this problem, I'd like to make the
Before I get flamed and down-voted without mercy, my company will not allow the
Ok, before I get a ton of responses. I know you cannot talk to

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.