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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:01:46+00:00 2026-05-14T15:01:46+00:00

I am unable to convert JSON string to .net object in asp.net. I am

  • 0

I am unable to convert JSON string to .net object in asp.net. I am sending JSON string from client to server using hidden field (by keeping the JSON object.Tostring() in hidden field and reading the hidden field value in code behind file)

Json string/ Object:

 [[{"OfferId":"1","OrderValue":"11","HostingTypeID":"3"},
{"OfferId":"1","OrderValue":"11","HostingTypeID":"3"},
{"OfferId":"1","OrderValue":"11","HostingTypeID":"3"},
{"OfferId":"1","OrderValue":"2","HostingTypeID":"3"},
{"OfferId":"1","OrderValue":"2","HostingTypeID":"3"},
{"OfferId":"1","OrderValue":"67","HostingTypeID":"3"},
{"OfferId":"1","OrderValue":"67","HostingTypeID":"3"}],
[{"OfferId":"1","OrderValue":"99","HostingTypeID":"6"}],
[{"OfferId":"1","OrderValue":"10","HostingTypeID":"8"}]]

.Net Object

public class JsonFeaturedOffer
{
    public string OfferId { get; set; }

    public string OrderValue { get; set; }

    public string HostingTypeID { get; set; }
}

Converstion code in code behind file

byte[] byteArray = Encoding.ASCII.GetBytes(HdnJsonData.Value);
        MemoryStream stream = new MemoryStream(byteArray);
        DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(JsonFeaturedOffer));
        object result= serializer.ReadObject(stream);
        JsonFeaturedOffer jsonObj = result as JsonFeaturedOffer;

While converting i am getting following error:

Expecting element ‘root’ from namespace ”.. Encountered ‘None’ with name ”, namespace ”.

  • 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-14T15:01:46+00:00Added an answer on May 14, 2026 at 3:01 pm

    Instead of doing this manually I would recommend using the built in lightweight JavaScriptSerializer. No attributes are required on the classes you want to serialize/deserialize.

    It’s also more flexible and faster than the DataContractJsonSerializer, since it does not have to care about all the wcf stuff. Additionally it has generic overloads that make it very simple to use AND it can also handle anonymous types.

    Serialization:

    var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
    var objectAsJsonString = serializer.Serialize(objectToSerialize);
    

    Deserialization:

    var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
    JsonFeaturedOffer deserializedObject = serializer.Deserialize<JsonFeaturedOffer>(s_JsonBaseDate);
    

    To make it even easier you can create Extension methods that will give you json serialization/deserialization directly on the objects/strings.

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

Sidebar

Related Questions

I am unable to consume messages sent via ActiveMQ from my Flex client. Sending
Why is the compiler unable to infer the correct type for the result from
How do I solve the error: Unable to read WSDL from URL: https://workflowtest.site.edu/_vti_bin/Lists.asmx?WSDL .
Unable to find a SQL diff tool that meets my needs, I am writing
I have been unable to receive UDP multicast under VxWorks 5.5. I've joined the
I am unable to create an empty solution in Visual Studio. The msdn documentation
I have been unable to trigger an onselect event handler attached to a <div>
C++ is unable to make a template out of a typedef or typedef a
I've been unable to build P4Python for an Intel Mac OS X 10.5.5. These
I am unable to implement PageMethods feature of the scriptmanager in a usercontrol, is

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.