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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:53:20+00:00 2026-06-17T23:53:20+00:00

I’m developing an application that reads some JSON data and makes some statistics, but

  • 0

I’m developing an application that reads some JSON data and makes some statistics, but now I’ve run into a problem.

I have a string like this:

{
"position":[
  {
     "someKey1":"someVal1",
     "someKey2":"someVal2",
  },
  {
     "someKey1":"someVal3",
     "someKey2":"someVal4",
  }
}

I want to access the someKeys and someValues.

I’m converting it to a dictionary like this:

Dictionary<string, object> values = deserializeJSON(json_string);

Edit 1: Sorry, forgot to add deserializeJSON:

private Dictionary<string, object> deserializeJSON(string p_jsonObject)
{
    JavaScriptSerializer serializer = new JavaScriptSerializer();
    return serializer.Deserialize<Dictionary<string, dynamic>>(p_jsonObject);
}

Now I have trouble getting access to the list of values with the key “position”. If I try to print the type of values[“position”] I get:

System.Collections.ArrayList

So I thought I could just iterate through this, but I can’t. I tried using enumerator (read in here that it would make it possible to iterate over the objects, and that I have to add it to an ArrayList to cast it):

ArrayList arr = new ArrayList();
IEnumerable enumerable = values["position"] as IEnumerable;

foreach (object element in enumerable)
{
    arr.Add(element);
}

When I print arr[0] I get:

System.Collections.Generic.Dictionary`2[System.String,System.Object]

Here I’m confused. I assume it’s the list of someKeys and someVals, which should be correct, right?
Now I’ve tried, with no luck, getting access to these values. I tried arr[0][“someKey1”] but get an error that I cannot apply indexing to ‘object’.

Any ideas on a solution? Ideally a more elegant solution? 🙂

Thanks in advance

  • 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-17T23:53:21+00:00Added an answer on June 17, 2026 at 11:53 pm

    You can use Linq to JSON (add Newtonsoft’s JSON.NET from NuGet):

    JObject jo = JObject.Parse(json);
    var value = (string)jo["position"][1]["someKey1"]; // someVal3
    

    Another sample:

    JObject jo = JObject.Parse(json);
    JArray positions = (JArray)jo["position"];
    foreach (var item in positions)
    {
        // use (string)item["someKey1"]
        // use (string)item["someKey2"]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to construct a data frame in an Rcpp function, but when I
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
I am using jsonparser to parse data and images obtained from json response. When
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.