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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:57:07+00:00 2026-05-31T02:57:07+00:00

When using the Microsoft namespaces System.Web.Helpers and System.Web.Script.Serialization I expected that the Microsoft serializer

  • 0

When using the Microsoft namespaces System.Web.Helpers and System.Web.Script.Serialization I expected that the Microsoft serializer played well with Microsofts dynamic JSON object. It turns out that this was a naive assumption. The JavaScriptSerializer serializes the object to “{}”. What is the recommended way for this seemingly trivial task?

     dynamic obj = new DynamicJsonObject(new Dictionary<string,object>());
     obj.FirstName = "Henry";
     obj.LastName = "Ford";
     JavaScriptSerializer jsc = new JavaScriptSerializer();
     string str = jsc.Serialize( obj );
     Assert.AreNotEqual(str, "{}"); // Does not fail
  • 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-31T02:57:08+00:00Added an answer on May 31, 2026 at 2:57 am

    Try Json.Net

    dynamic obj = new DynamicJsonObject(new Dictionary<string,object>());
    obj.FirstName = "Henry";
    obj.LastName = "Ford";
    string str = JsonConvert.SerializeObject(obj);
    

    It will do it successfully. You can use it with anonymous classes

    string s = JsonConvert.SerializeObject(new {FirstName="Henry",LastName="Ford"});
    

    and ExpandoObjects too

    dynamic obj = new ExpandoObject();
    obj.FirstName = "Henry";
    obj.LastName = "Ford";
    string s = JsonConvert.SerializeObject(obj);
    

    Deserialization to dynamic objects is also possible

    dynamic obj2 = JsonConvert.DeserializeObject(@"{""FirstName"":""Henry"",""LastName"":""Ford""}");
    Console.WriteLine(obj2.FirstName + " " + obj2.LastName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Regardless of whether my machines's root web config (the one in Windows/Microsoft.NET/...) contains system.web/pages/namespaces/add
When manipulating Handler Mappings using the Microsoft.Web.Administration namespace, is there a way to remove
I am using Microsoft Visual Web Developer 2008 Express. I've made an ASP.NET MVC
I'm using Microsoft Visual C# 2008 Express. In my main form, there's that X
I am using the Microsoft.Build.BuildEngine to build a number of projects. Projects that do
I'm working on a web client. Here is the code: using System.Net; using System.Net.Sockets;
Using Microsoft SQL Server's database mirroring capability, can the mirroring occur between two clusters?
When using Microsoft office automation I want to insert images into a spreadsheet. How
I am using Microsoft Access 2007 to move and massage some data between two
I'm using Microsoft.XMLHTTP to get some information from another server from an old ASP/VBScript

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.