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

  • Home
  • SEARCH
  • 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 8794409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:14:50+00:00 2026-06-13T23:14:50+00:00

In my controller, I get a string that is JSON: String json_string = this.Request.Content.ReadAsStringAsync().Result;

  • 0

In my controller, I get a string that is JSON:

String json_string = this.Request.Content.ReadAsStringAsync().Result;

That looks something like so:

{
    "21": {"Id":21,"DisplayOrder":3, ... snip ... },
    "333":{"Id":333,"DisplayOrder":2, ... snip ... },
    "591":{"Id":591,"DisplayOrder":1, ... snip ... }
}

I don’t have a say in the structure of this JSON so can’t format it into something without keys. They keys aren’t necessary since the ID is within the Value of that Dictionary.

In any case, how do I convert json_string in such a way that allows me to pull out the only two items I want when I iterate over the ‘rows’ in that structure… Id, DisplayOrder?

Like so:

int Id = row_item.Id;
int DisplayOrder = row_item.DisplayOrder;

Thanks!
Eric

  • 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-13T23:14:51+00:00Added an answer on June 13, 2026 at 11:14 pm
    string json = @"{
        ""21"": {""Id"":21,""DisplayOrder"":3},
        ""333"":{""Id"":333,""DisplayOrder"":2},
        ""591"":{""Id"":591,""DisplayOrder"":1}}";
    
    var list = new JavaScriptSerializer()
                   .Deserialize<Dictionary<string, Dictionary<string, object>>>(json)
                   .Values
                   .ToList();
    
    Console.WriteLine(list[0]["Id"]); // <--21
    

    You can also do the same thing with Json.Net

    var jObj = JsonConvert
               .DeserializeObject<Dictionary<string, Dictionary<string, object>>>(json)
               .Values
               .ToList();
    
    Console.WriteLine(jObj[0]["Id"]);
    

    dynamic can be utilized too

    var jObj = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(json)
                .Values
                .ToList();
    
    Console.WriteLine(jObj[0].DisplayOrder);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a json string back from my controller, that is prefill-values
My controller is like this @RequestMapping(value =/getTaggedProducts, method = RequestMethod.GET) @ResponseBody public String getProductsTagged(@RequestParam(questionnaireId)Long
I have a controller (Spring-MVC) that generates a PDF report on a get request.
Suppose I have a controller that serves GET request and returns bean to be
I've got a JSON string that I'm posting to my Python script. This is
In my controller: @RequestMapping(value = /, method = RequestMethod.GET) public String index() { return
Inside Controller I need to get a rendered string and do some actions with
I want to generate an url like this: /photo?tags=tag1,tag2,tag3 routes file: GET /photo controllers.Photos.list(tags:Array[String]
I want to make a handler/controller for a GET request such as in ElasticSearch
I have a base controller class that attempts to look at Request.ContentType to see

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.