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

The Archive Base Latest Questions

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

I have the following Dictionary<> object: Dictionary<String, object> parameters = new Dictionary<string, object>(); parameters.Add(username,

  • 0

I have the following Dictionary<> object:

Dictionary<String, object> parameters = new Dictionary<string, object>();
parameters.Add("username", "mike");
parameters.Add("password", "secret");
parameters.Add("persist", false);

When I serialize it:

using (MemoryStream stream = new MemoryStream())
{
   DataContractJsonSerializer serializer = new DataContractJsonSerializer(parameters.GetType());
   serializer.WriteObject(stream, parameters);

   byte[] bytes = stream.ToArray();
   string json = Encoding.UTF8.GetString(bytes, 0, bytes.Length);

   return json;
}

I get the following:

"[{\"Key\":\"username\",\"Value\":\"mike\"},{\"Key\":\"password\",\"Value\":\"secret\"},{\"Key\":\"persist\",\"Value\":false}]"

What I want to get is a raw key/value pair map, like so:

"{\"username\":\"mike\", \"password\":\"secret\", \"persist\": false}"

I’ve tried setting UseSimpleDictionaryFormat to true, but this property has no effect nor is its intended use documented anywhere I can find.

I can’t use a custom class, since the parameter key/value pairs is not known at compile time.

I also cannot use a third party library, such as JSon.NET. I’m using the Silverlight framework and the Windows Phone 8 runtime.

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

    Try serializing this

    var parameters = new
    {
        username = "mike",
        password = "secret",
        persist = false
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following nested dictionaries: Dictionary<int, Dictionary<string, object>> x; Dictionary<int, SortedDictionary<long, Dictionary<string, object>>>
I have the following decleration: private Dictionary<string, Dictionary<string, File>> listFiles = new Dictionary<string,Dictionary<string,File>>(); How
I have the following classes: public class DictionaryBuilder<T> where T : IDictionary<string, object>, new()
I have data on following variables. CryptoStream searialNumber = encryptedSearialNumber; Dictionary<string, object> x= userInput;
I have the following code: // Dictionary which I want to optimize Dictionary<string, MyClass>
I have a method with the following signature: public ActionResult RenderFamilyTree(string name, Dictionary<string, string>
I have a dictionary<String,Object> and I want to convert it to a List<Customer> Is
I have the following City class. Each city object contains a dictionary which keys
I have a Dictionary<string, object> dictionary. It used to be Dictionary<Guid, object> but other
I have the following classes: public class BagA : Dictionary<string, BagB> {} public class

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.