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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:39:58+00:00 2026-06-01T06:39:58+00:00

I need to select some values from a json response. Im using json.net, fine

  • 0

I need to select some values from a json response. Im using json.net, fine with the simpler stuff, but there doesnt seem to be much documentation/tutorials on anything past that. In the json example below i need to select all the ages:

{
"teacherHolder": [{
    "id": 200000001,
    "name": "Mr Test",
    "class": "a4",
    "students": [{
        "id": "100532469",
        "name": "ben"
    },
    {
        "id": "100506025",
        "name": "bill"
    },
    {
        "id": "100000447",
        "name": "bob"
    }]

}]

}

I have tried this and other variations:

var stuff = response["teacherHolder"].Children()["students"];

var names = from y in stuff.Children().Values()
                    select y["name"];

and this:

var names= response["teacherHolder"]
            .Select(s => (string)s.SelectToken("students[0].name")).ToList();

response is a JObject from a webrequest.
I just get back this:

[{"Key":"Newtonsoft.Json.Linq.JEnumerable`1[Newtonsoft.Json.Linq.JToken]","Value":"Newtonsoft.Json.Linq.JEnumerable`1[Newtonsoft.Json.Linq.JToken]"}]

The results are eventually put into a dictionary.

Any idea how to do this? i know it will be simple, i just havent found the right combination.

  • 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-01T06:40:00+00:00Added an answer on June 1, 2026 at 6:40 am

    If you want to get the names of all students of all teachers, you can do it for example like this:

    var students = response["teacherHolder"].Children()["students"];
    
    var names = students.Children()["name"];
    

    Or, as another option:

    var names = from teacher in response["teacherHolder"]
                from student in teacher["students"]
                select student["name"];
    

    If you want them as IEnumerable<string>, just add Value<string>() at the end of the select. Or add Values<string>(), if you with the first option.

    But it’s usually better to create types for your object model, so that you can work with them as with normal objects and not as some special JSON objects.

    If you have that, you could do something like:

    var names = from teacher in response.TeacherHolder
                from student in teacher.Students
                select student.Name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to select some values from a table to be updated, and then
I need to select some values from an Informix database via Oracle ODBC. One
I need to select all columns from two tables, but need to be able
I need to select 5 most recent rows from cached Dataview object, is there
I need to select some records from a table where a column value is
I need some help with a query. i want to select from a table,
I need to select some rows that don't have certain values in 2 columns.
I need to select and update a table looking up values from other tables.
I'm trying to get some aggregate values from different tables, but my problem is
Suppose i have 1kk records in my database. Now i need to select some

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.