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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:55:30+00:00 2026-05-17T02:55:30+00:00

I have a file in JSON format with record for individual users. Some of

  • 0

I have a file in JSON format with record for individual users. Some of the users have a comment field stuck in the middle of their records. I just want to parse top-level items (
fullName
contributorName
email)

using the Newtonsoft.JSON parser, but I can’t seem to get it to recognize individual objects. When I parse the whole string into one big object, I don’t know how to iterate the individual ones.

This is how I was trying to do it (property by property), but it didn’t work if they were out of order or had subproperties. I need to put it into an object instead:

StreamReader re = File.OpenText("C:\\dropbox\\my dropbox\\clients\\towson\\english 317\\Ning Archive\\ning-members.json");
JsonTextReader reader = new JsonTextReader(re);
string ct = "";

try
{
    ct += "<table style='border:1px solid black'>";
    while (reader.Read())
    {
        if (reader.TokenType == JsonToken.PropertyName)
        {
            if (reader.Value.ToString() == "fullName")
            {
                reader.Read();
                ct += "\r\n\r\n<tr><td>" + reader.Value + "</td>";
            }
            if (reader.Value.ToString() == "contributorName")
            {
                reader.Read();
                ct += "<td>" + reader.Value + "</td></tr>";
            }
            if (reader.Value.ToString() == "email")
            {
                reader.Read();
                ct += "<td>" + reader.Value + "</td>";
            }
        }
    }       
}
catch { }

ct+="</table>";
namesText.Text = ct;

Note the first record has a comments field that I don’t care about, but gets in the way of the order when I try to parse as a stream.

[
{
    "createdDate": "2010-09-10T14:16:08.271Z",
    "fullName": "Lisa Meloncon",
    "gender": "f",
    "country": "US",
    "birthdate": "1969-05-14",
    "comments": [
        {
            "id": "6292914:Comment:272",
            "contributorName": "0upfj0fd33932",
            "description": "Thanks for joining! I'm working up a schedule for the students a bit late so I can assess some of their early writing (including the first assignment, a general evaluation of business writing skills) and determine a course that will address their needs. I plan to make liberal use of technology this semester, with a Screencasting assignment, some intermediate Word formatting drills, and various other activities.",
            "createdDate": "2010-09-10T18:07:38.272Z"
        }
    ],
    "email": "meloncon@xxx.com",
    "profilePhoto": "http://api.ning.com:80/files/251IcCtIBC3dGALHpG3ruYfg0Ip*EFJApPyMVGkiVArSUEvF*dK8A5grvPvl8eC7i7H0grhRH4pakLc9jSOww2GpU2OTq2nq/626617250.png?crop=1%3A1",
    "level": "member",
    "state": "active",
    "contributorName": "2z42css3dgvoi"
},
{
    "createdDate": "2010-09-08T02:57:00.225Z",
    "fullName": "Robert Calabrese",
    "gender": "m",
    "location": "Baltimore, MD",
    "country": "US",
    "zip": "21284",
    "birthdate": "1989-09-29",
    "email": "rcalab2@xxx.edu",
    "profilePhoto": "http://api.ning.com:80/files/251IcCtIBC3dGALHpG3ruYfg0Ip*EFJApPyMVGkiVArSUEvF*dK8A5grvPvl8eC7i7H0grhRH4pakLc9jSOww2GpU2OTq2nq/626617250.png?crop=1%3A1",
    "level": "member",
    "state": "active",
    "contributorName": "199ru4hzwc4n4"
},
{
    "createdDate": "2010-09-04T22:36:51.158Z",
    "fullName": "Regis Bamba",
    "gender": "m",
    "location": "Baltimore, MD",
    "country": "US",
    "zip": "21210",
    "birthdate": "1986-09-29",
    "email": "rbamba2xxx.edu",
    "profilePhoto": "http://api.ning.com:80/files/251IcCtIBC3dGALHpG3ruYfg0Ip*EFJApPyMVGkiVArSUEvF*dK8A5grvPvl8eC7i7H0grhRH4pakLc9jSOww2GpU2OTq2nq/626617250.png?crop=1%3A1",
    "level": "member",
    "state": "active",
    "contributorName": "2seadgzt89n6x"
},
  • 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-17T02:55:31+00:00Added an answer on May 17, 2026 at 2:55 am

    Something like:

    JArray root = JArray.Load(reader);
    foreach(JObject o in root)
    {
        ct += "\r\n\r\n<tr><td>" + (string)o["fullName"] + "</td>";
        ct += "<td>" + (string)o["contributorName"] + "</td>";
        ct += "<td>" + (string)o["email"] + "</td>";
    }
    

    We use an explicit conversion to get a string value from the JToken returned by JObject.Item.

    However, you should consider using StringBuilder, rather than concatenation, for performance.

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

Sidebar

Related Questions

No related questions found

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.