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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:23:56+00:00 2026-05-29T11:23:56+00:00

I am currently working with json.net ! I know how to deserialize json data

  • 0

I am currently working with json.net ! I know how to deserialize json data and how to map with our class. Now I am eager about some queries !

Suppose my jsonstrings is

"attributes":{
            "color":"Brown",
            "condition":"Used",
            "currency":"USD",
            "price":"10500",
            "price_display":"$10,500",
         }

and my attribute class ( in which i want to deserialize above string) is

Public class Attribute
{
        public string name{ get; set; }
        public string value{ get; set; }
}

Now I am using following code for deserialization.!

 JavaScriptSerializer ser = new JavaScriptSerializer();
 <classname> p = ser.Deserialize<classname>(jsonString);

And Obviously this code is not going to work for above jsonstring at all.

Now How can I bind these name value pair in one class ?? Is this possible ?

In future, attributes may b more than 10 but format will be same as name value pair

  • 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-29T11:23:57+00:00Added an answer on May 29, 2026 at 11:23 am

    EDIT: I’m sorry, but somehow I interpreted your question as if you wanted to serialize, and not deserialize (but I’ll keep the original below anyway, as I think it’s good knowledge :)).

    Try to deserialize your JSON string to Dictionary<string,string> instead of your Attribute. I have a hunch it might work. Then, you can adjust the rest of your code to use that dictionary or you can convert to collection of your Attribute instances.


    The original answer (related to serializing, which was the opposite of what you asked for) below.

    I don’t think so, but if the intention is to use it on the client this way:

    attributes["color"] // returns Brown
    attributes["price"] // returns 10500
    

    … then what you’re after is called “associative array”, as it’s equivalent to this:

    attributes.color
    attributes.price
    

    … as it’s not really an array, but it’s an object (javascript provides these two ways to reference object properties; e.g. window.onload is the same as window["onload"])…

    … and you can achieve this with the JavaScriptSerializer if you serialize Dictionary<string,string> to JSON string (in other words, change your Attribute class to KeyValuePair<string,string>, or otherwise create such dictionary differently.

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

Sidebar

Related Questions

I am currently using Json.Net to deserialize my JSON. I now have the following
I have a working application using Json.NET (newtonsoft) as a custom serializer. Currently I'm
Currently working on a VBScript to automate some of the dirty PST ingestion work
Im currently working with an API which requires we send our collection details in
I am currently working on 2 .NET apps which must communicate with each other.
I'm currently working on cross domain data transfer and I've hit a really big
I am currently working on some prototypes for a web site I am wanting
I have been working on a JQuery script that posts JSON to my asp.net
I am currently deserializing JSON using XStream, and it has been working great. However,
I'm currently working on a ASP.NET Webforms site and I've run in to a

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.