0

I use this example to serialize a dictonary like this

Dictionary<object, object>

What I get is

{ "key": "value" }

what I need is

{ key: "value" }

How do I get this output?

6
  • What you need is not a valid json. jsonlint.com Commented Sep 13, 2013 at 8:11
  • well, yes :) any chance? Commented Sep 13, 2013 at 8:12
  • What if your dictionary contains a key like User Name? {User Name: "XmlmXmlmX"} is garbage. Commented Sep 13, 2013 at 8:14
  • problem is, both objects are already strings. Commented Sep 13, 2013 at 8:32
  • It seems to be an XY-Problem. (You want to do X, and you think Y is the best way of doing so. Instead of asking about X, you ask about Y.) Commented Sep 13, 2013 at 8:35

1 Answer 1

0

wrong approach - now I use a simple stringbuilder.

foreach (DictionaryEntry entry in xSet)
{
  result.AppendFormat("{0}: '{1}',", entry.Key, HttpUtility.JavaScriptStringEncode(entry.Value.ToString()));
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.