문제

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

도움이 되었습니까?

해결책

Define Dictionary object as

Dictionary<string, object>

instead of

Dictionary<string, string>.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top