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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:14:34+00:00 2026-06-16T22:14:34+00:00

I have a simple class: public class site { public string URL { get;

  • 0

I have a simple class:

public class site
        {
            public string URL { get; set; }
        }

That exists within a http handler. Currently I am posting json to this handler and trying to deserialize it to get the URL out of the string. I am however having a problem with the deserialize part of it.

I have a string “jsonString” that has the json formatted like so:

[{"URL":"http://www.google.com/etc/"}]

Here is my code for the deserialize:

JavaScriptSerializer jsonSerializer = new JavaScriptSerializer();

        string jsonString = String.Empty;

        HttpContext.Current.Request.InputStream.Position = 0;
        using (StreamReader inputStream = new StreamReader(HttpContext.Current.Request.InputStream))
        {
            jsonString = inputStream.ReadToEnd();
        }

        site currSite = new site();
        currSite = jsonSerializer.Deserialize<site>(jsonString);

        //set response types
        HttpContext.Current.Response.ContentType = "application/json";
        HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;


       //send response 
       HttpContext.Current.Response.Write(jsonSerializer.Serialize(currSite.URL));  

I am then trying to send a response using currSite.URL however it is failing. What am I missing here? I am reasonably confident it is at the deserialize part because if I send a response of jsonString instead of currSite.URL it will work.

  • 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-16T22:14:35+00:00Added an answer on June 16, 2026 at 10:14 pm

    Your json string shows that it’s an array, not a single entity. You should deserialize it as so:

    var result = jsonSerializer.Deserialize<site[]>(jsonString);
    

    And result[0].Url should contain what you are looking for.

    Update

    Adding sample code:

     string json = @"[{""URL"":""http://www.google.com/etc/""}]";
    
     JavaScriptSerializer js = new JavaScriptSerializer();
     var result = js.Deserialize<site[]>(json);
     Console.WriteLine(result[0].URL);
    

    Prints:
    http://www.google.com/etc/

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

Sidebar

Related Questions

I have an simple class that I get from a webservice. public class person
I have a model public class Person { public string Name { get; set;
I have a simple Java class that has some methods: public class Utils {
I have simple type Question : public class Question { public string[] Tags {
I have this simple class public class Position{ int x; int y; Position(int x,int
I have a simple class inheriting from WebControl as follow: public class Instrument :
If I have a simple class such as:- @XmlRootElement public class MyClass { @XmlAttribute(required=true)
I have a simple class Student under namespace School. namespace XmlTestApp { public class
All, I have a simple class. public class Container : UserControl { public bool
Say I have a simple address class like below: public class Address { public

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.