1

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

1

1 Answer 1

1

Define Dictionary object as

Dictionary<string, object>

instead of

Dictionary<string, string>.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.