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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:33:44+00:00 2026-06-11T11:33:44+00:00

I have a Json response that I receive from an API call. It has

  • 0

I have a Json response that I receive from an API call. It has several nested levels as show below (this is a snippet):

"Items": [
  {
    "Result": {
      "Id": "191e24b8-887d-e111-96ec-000c29128cee",
      "Name": "Name",
      "StartDate": "2012-04-03T00:00:00+01:00",
      "EndDate": null,
      "Status": {
        "Name": "Active",
        "Value": 5
      },
      "Client": {
        "Id": "35ea10da-b8d5-4ef8-bf23-c829ae90fe60",
        "Name": "client Name",
        "AdditionalItems": {}
      },
      "ServiceAgreement": {
        "Id": "65216699-a409-44b0-8294-0e995eb05d9d",
        "Name": "Name",
        "AdditionalItems": {
          "ScheduleBased": true,
          "PayFrequency": {
            "Id": "981acb72-8291-de11-98fa-005056c00008",
            "Name": "Weekly",
            "AdditionalItems": {}
          },
          "PayCycle": [
            {
              "Name": "Schedule Based",
              "ScheduleBased": true,
              "SelfBilling": false,
              "Id": "a8a2ecc4-ff79-46da-a135-743b57808ec3",
              "CreatedOn": "2011-09-16T23:32:19+01:00",
              "CreatedBy": "System Administrator",
              "ModifiedOn": "2011-09-16T23:32:19+01:00",
              "ModifiedBy": "System Administrator",
              "Archived": false
            }
          ]
        }
      },
}
]
...

What I want to do is retreive the data from the PayCycle node using Linq. I can for example get the items with a value of true using Result.ServiceAgreement.AdditionalItems.SchedultedBased using the following Linq in the Controller:

var result = from p in data["Data"]["Items"].Children()
             where (bool)p["Result"]["ServiceAgreement"]["AdditionalItems"]["ScheduleBased"] == true
             select new
             {
                 Name = (string)p["Result"]["Client"]["Name"],
                 Id = (string)p["Result"]["Client"]["Id"]
             };

Now I need to get Result.ServiceAgreement.AdditionalItems.Paycycle.ScheduleBased and SelfBilling properties. How do I do this if PayCycle is also an array, how do I get the children as I did with Data.Items in the Linq above so that I can have the where clause filter on both these items?

  • 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-06-11T11:33:46+00:00Added an answer on June 11, 2026 at 11:33 am

    You can deserialize the JSON into a dynamic object, and then use Linq to Objects:

        [TestMethod]
        public void TestMethod1()
        {
            const string json = @"""Items"": [
    {
    ""Result"": {
      ""Id"": ""191e24b8-887d-e111-96ec-000c29128cee"",
      ""Name"": ""Name"",
      ""StartDate"": ""2012-04-03T00:00:00+01:00"",
      ""EndDate"": null,
      ""Status"": {
        ""Name"": ""Active"",
        ""Value"": 5
      },
      ""Client"": {
        ""Id"": ""35ea10da-b8d5-4ef8-bf23-c829ae90fe60"",
        ""Name"": ""client Name"",
        ""AdditionalItems"": {}
      },
      ""ServiceAgreement"": {
        ""Id"": ""65216699-a409-44b0-8294-0e995eb05d9d"",
        ""Name"": ""Name"",
        ""AdditionalItems"": {
          ""ScheduleBased"": true,
          ""PayFrequency"": {
            ""Id"": ""981acb72-8291-de11-98fa-005056c00008"",
            ""Name"": ""Weekly"",
            ""AdditionalItems"": {}
          },
          ""PayCycle"": [
            {
              ""Name"": ""Schedule Based"",
              ""ScheduleBased"": true,
              ""SelfBilling"": false,
              ""Id"": ""a8a2ecc4-ff79-46da-a135-743b57808ec3"",
              ""CreatedOn"": ""2011-09-16T23:32:19+01:00"",
              ""CreatedBy"": ""System Administrator"",
              ""ModifiedOn"": ""2011-09-16T23:32:19+01:00"",
              ""ModifiedBy"": ""System Administrator"",
              ""Archived"": false
            }
          ]
        }
      }
    }
    }
    ]";
            dynamic data = System.Web.Helpers.Json.Decode("{" + json + "}");
    
            var result = from i in (IEnumerable<dynamic>)data.Items
                         where i.Result.ServiceAgreement.AdditionalItems.ScheduleBased == true
                         select new
                                {
                                    i.Result.Client.Name,
                                    i.Result.Client.Id
                                };
    
            Assert.AreEqual(1, result.Count());
            Assert.AreEqual("client Name", result.First().Name);
            Assert.AreEqual("35ea10da-b8d5-4ef8-bf23-c829ae90fe60", result.First().Id);
        }
    

    Note that I had to add brackets { and } around your example json string, or else the .NET json parser doesn’t like it.

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

Sidebar

Related Questions

I have a JSON response that is formatted from my C# WebMethod using the
Basically, I have a JSON response from the Twitter API containing a timeline. I
I have this JSON response string: {d:{\ID_usuario\:\000130\,\Nombre\:null,\Vipxlo\:0,\Provmun\:null,\Descuentos\:null,\Listaviplocal\:null}}` With this code: - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
If i have this json response {error:repeated} Why the alert is not showed? It
I have a web service that receives requests from users and returns some json.
I have a page that receives a JSON response. If there is more than
I have a WCF service that returns JSON to the clients. This is the
This is a simplification, but I have an app that has the following methods:
I have a json response like: { total: 2, success: true, rows: [ {a1_id:7847TK10,
We have a JSON response which can contain null values (e.g. { myValue: null

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.