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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:50:25+00:00 2026-05-31T06:50:25+00:00

I am using an API that outputs JSON objects with many attributes including sub-objects.

  • 0

I am using an API that outputs JSON objects with many attributes including sub-objects. So far all of the examples that I have found for JSON in C# assume that the .Net object has been serialized to JSON and can be deserialized back into the .Net object.

I am trying to find a solution where I can read the JSON into some generic object that I can then manually assign values to my Business Object properties by selecting the values from the generic objects.

Possibly something like ADO.Nets Datables and DataRows where you can pass the column names to the DataRow objects and get the values of the columns. This may be a bit too advanced but basically I want to be able to read the JSON objects by iterating through them and select values from the objects by passing the attribute names. This means that I won’t be deserializing all of the attributes into my business objects, I will just be taking specific attributes from the JSON objects and assigning their values to the properties of my business objects.

What is a good solution for doing this?

Here is an example of two objects output from the API:

{
  "appt": [
    {
      "d": 1331717080000, 
      "id": "112115", 
      "inv": [
        {
          "comp": [
            {
              "alarm": [
                {
                  "action": "DISPLAY", 
                  "desc": [
                    {}
                  ], 
                  "trigger": [
                    {
                      "rel": [
                        {
                          "m": 5, 
                          "neg": true, 
                          "related": "START"
                        }
                      ]
                    }
                  ]
                }
              ], 
              "apptId": "112115", 
              "calItemId": "112115", 
              "ciFolder": "112111", 
              "class": "PUB", 
              "compNum": 0, 
              "d": 1331717080000, 
              "desc": [
                {
                  "_content": ""
                }
              ], 
              "descHtml": [
                {
                  "_content": "<html><body></body></html>"
                }
              ], 
              "e": [
                {
                  "d": "20120314T130000", 
                  "tz": "Pacific/Auckland", 
                  "u": 1331683200000
                }
              ], 
              "fb": "B", 
              "fba": "B", 
              "isOrg": true, 
              "loc": "", 
              "method": "PUBLISH", 
              "name": "Test Appt", 
              "noBlob": true, 
              "or": {
                "a": "liam@url.com", 
                "d": "Liam Smith", 
                "url": "liam@url.com"
              }, 
              "rsvp": false, 
              "s": [
                {
                  "d": "20120314T090000", 
                  "tz": "Pacific/Auckland", 
                  "u": 1331668800000
                }
              ], 
              "seq": 0, 
              "status": "CONF", 
              "transp": "O", 
              "uid": "aa2e4fe4-c636-4660-ae92-3e7041fe5669", 
              "url": "", 
              "x_uid": "aa2e4fe4-c636-4660-ae92-3e7041fe5669"
            }
          ], 
          "compNum": 0, 
          "id": 112114, 
          "seq": 0, 
          "type": "appt", 
          "tz": [
            {
              "daylight": [
                {
                  "hour": 2, 
                  "min": 0, 
                  "mon": 9, 
                  "sec": 0, 
                  "week": -1, 
                  "wkday": 1
                }
              ], 
              "dayname": "NZDT", 
              "dayoff": 780, 
              "id": "Pacific/Auckland", 
              "standard": [
                {
                  "hour": 3, 
                  "min": 0, 
                  "mon": 4, 
                  "sec": 0, 
                  "week": 1, 
                  "wkday": 1
                }
              ], 
              "stdname": "NZST", 
              "stdoff": 720
            }
          ]
        }
      ], 
      "l": "112111", 
      "rev": 72672, 
      "s": 0, 
      "uid": "aa2e4fe4-c636-4660-ae92-3e7041fe5669"
    }, 
    {
      "d": 1331717176000, 
      "id": "112117", 
      "inv": [
        {
          "comp": [
            {
              "alarm": [
                {
                  "action": "DISPLAY", 
                  "desc": [
                    {}
                  ], 
                  "trigger": [
                    {
                      "rel": [
                        {
                          "m": 5, 
                          "neg": true, 
                          "related": "START"
                        }
                      ]
                    }
                  ]
                }
              ], 
              "apptId": "112117", 
              "calItemId": "112117", 
              "ciFolder": "112111", 
              "class": "PUB", 
              "compNum": 0, 
              "d": 1331717176000, 
              "desc": [
                {
                  "_content": ""
                }
              ], 
              "descHtml": [
                {
                  "_content": "<html><body></body></html>"
                }
              ], 
              "e": [
                {
                  "d": "20120315T120000", 
                  "tz": "Pacific/Auckland", 
                  "u": 1331766000000
                }
              ], 
              "fb": "B", 
              "fba": "B", 
              "isOrg": true, 
              "loc": "", 
              "method": "PUBLISH", 
              "name": "test 2", 
              "noBlob": true, 
              "or": {
                "a": "liam@url.com", 
                "d": "Liam Smith", 
                "url": "liam@url.com"
              }, 
              "rsvp": false, 
              "s": [
                {
                  "d": "20120315T100000", 
                  "tz": "Pacific/Auckland", 
                  "u": 1331758800000
                }
              ], 
              "seq": 0, 
              "status": "CONF", 
              "transp": "O", 
              "uid": "4081f711-9742-42bd-a5dc-8bc9ddc3305d", 
              "url": "", 
              "x_uid": "4081f711-9742-42bd-a5dc-8bc9ddc3305d"
            }
          ], 
          "compNum": 0, 
          "id": 112116, 
          "seq": 0, 
          "type": "appt", 
          "tz": [
            {
              "daylight": [
                {
                  "hour": 2, 
                  "min": 0, 
                  "mon": 9, 
                  "sec": 0, 
                  "week": -1, 
                  "wkday": 1
                }
              ], 
              "dayname": "NZDT", 
              "dayoff": 780, 
              "id": "Pacific/Auckland", 
              "standard": [
                {
                  "hour": 3, 
                  "min": 0, 
                  "mon": 4, 
                  "sec": 0, 
                  "week": 1, 
                  "wkday": 1
                }
              ], 
              "stdname": "NZST", 
              "stdoff": 720
            }
          ]
        }
      ], 
      "l": "112111", 
      "nextAlarm": 1331758500000, 
      "rev": 72674, 
      "s": 0, 
      "uid": "4081f711-9742-42bd-a5dc-8bc9ddc3305d"
    }
  ]
}
  • 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-31T06:50:27+00:00Added an answer on May 31, 2026 at 6:50 am

    If your are using Json.Net you can make use of dynamic keyword. Here is a sample code using your json string.

    dynamic obj = JsonConvert.DeserializeObject(jsonstr);
    Console.WriteLine("{0} {1}", obj.appt[0].inv[0].comp[0].method, obj.appt[1].id);
    

    or

    foreach (var appt in obj.appt)
    {
        Console.WriteLine("{0} {1}", appt.inv[0].comp[0].method, appt.id);
    }
    

    in case you are using a framerork < 4.0, an uglier usage is also possible

    JObject obj = (JObject)JsonConvert.DeserializeObject(jsonstr);
    foreach (var appt in obj["appt"])
    {
        Console.WriteLine("{0} {1}", appt["inv"][0]["comp"][0]["method"], appt["id"]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a need to create a transactional process using an external API that
I have a program that creates a Windows user account using the NetUserAdd() API
I have this code that will return keyword suggestion from yahoo using the api.
Using the Twitter Search API I have attempted to download JSON data from a
I'm using an API that requires me to pass a function pointer as a
I'm using a Python API that expects me to pass it a function. However,
Situation: I need to make an imap client (using java mail api) that if,
I'm developing a API that uses lambda expressions to specify properties. I'm using this
I am trying to read some settings from php.ini using zend. The API that
I understand that using the facebook API I need an api key to connect,

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.