Question

I have a Dictionary like that:

Dictionary<string, string> // key value pair

and the example values are:

Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("key1","value1");
parameters.Add("products","[{"name":"Widget A","qty":3},{"name":"Widget B","qty":1}]");

how Can I serialize that as :

vars={"key1":"value1",products":[{"name":"Widget A","qty":3},{"name":"Widget B","qty":1}]} 

When I try to serialize :

vars={"key1":"value1",products":**"**[{"name":"Widget A","qty":3},{"name":"Widget B","qty":1}]**"**} 

its append double quotes. Using JSON.Net

I'm using third party API and it accepts HashTable for parameters.

thanks

Was it helpful?

Solution

Define Dictionary object as

Dictionary<string, object>

instead of

Dictionary<string, string>.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top