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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:17:48+00:00 2026-05-21T04:17:48+00:00

the json file’s structure which I will deserialize looks like below; { id :

  • 0

the json file’s structure which I will deserialize looks like below;

{
    "id" : "1lad07",
    "text" : "test",
    "url" : "http:\/\/twitpic.com\/1lacuz",
    "width" : 220,
    "height" : 84,
    "size" : 8722,
    "type" : "png",
    "timestamp" : "Wed, 05 May 2010 16:11:48 +0000",
    "user" : {
        "id" : 12345,
        "screen_name" : "twitpicuser"
    }
}

I have created a class which has the filed names as properties for JavaScriptSerializer. The code which I will use to Deserialize the json is as follows;

            using (var reader = new StreamReader(twitpicResponse.GetResponseStream())) {


                var responseBody = reader.ReadToEnd();
                var deserializer = new JavaScriptSerializer();
                var results = deserializer.Deserialize<Response>(responseBody);

            }

My problem is how I can read the user field on json file. which is like below;

"user" : {
    "id" : 12345,
    "screen_name" : "twitpicuser"
}

it has sub properties and values. how can I name them on my Response class. my response class now look like this;

public class Response {

    public string id { get; set; }
    public string text { get; set; }
    public string url { get; set; }
    public string width { get; set; }
    public string height { get; set; }
    public string size { get; set; }
    public string type { get; set; }
    public string timestamp { get; set; }

}

what is the best case to do it?

  • 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-21T04:17:49+00:00Added an answer on May 21, 2026 at 4:17 am
    1. You need to create a class that holds the user values, just like the response class User.
    2. Add a property to the Response class ‘user’ with the type of the new class for the user values User.

      public class Response {
      
          public string id { get; set; }
          public string text { get; set; }
          public string url { get; set; }
          public string width { get; set; }
          public string height { get; set; }
          public string size { get; set; }
          public string type { get; set; }
          public string timestamp { get; set; }
          public User user { get; set; }
      
      }
      
      public class User {
      
          public int id { get; set; }
          public string screen_name { get; set; }
      
      }
      

    In general you should make sure the property types of the json and your CLR classes match up. It seems that the structure that you’re trying to deserialize contains multiple number values (most likely int). I’m not sure if the JavaScriptSerializer is able to deserialize numbers into string fields automatically, but you should try to match your CLR type as close to the actual data as possible anyway.

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

Sidebar

Related Questions

I have a text file that is formatted like JSON, but in a print/view
I have a JSON file which I need to iterate over, as shown below...
When I try to use curl or file_get_contents to read something like http://example.com/python/json/ from
I have a json file/stream, i like to be able to make select SQL
I am trying to parse a Json file like this, generated by Exiftool: [{
I am writing a JSON file, but I am not sure about which of
I have a json file with contents like this: { aaa:{ status:available, classkey:dotnet },
I have one JSON file like following: {entries:[{title:‘foo’,id:‘01’,created:‘2010-12-06’},{title:‘bar’,id:‘02’,created:‘2010-12-05’}]} And also I have one html
I have a json file that's like for e.g. [{fu: thejimjams, su: 232104580}, {fu:
This is part of my JSON file I obtain through the twitter API: text:Scientists

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.