You need to serialize your dictionary to JSON string, am i right?
then you can use something like this..
Dictionary> foo = new Dictionary>();
foo.Add(1, new List() { new user() { test1 = 1, test2 = 1 }
, new user() { test1 = 2, test2 = 2 } });
foo.Add(2, new List() { new user() { test1 = 3, test2 = 3 }
, new user() { test1 = 4, test2 = 4 } });
string json = Newtonsoft.Json.JsonConvert.SerializeObject(foo);
it will populating your json string like this...
{"1":[{"test1":1,"test2":1},{"test1":2,"test2":2}],"2":[{"test1":3,"test2":3},{"test1":4,"test2":4}]}
I have use Newtonsoft.Json library to serialize your object, you can use this nuget package from here
https://www.nuget.org/packages/Newtonsoft.Json/[
^]
referance :
http://www.newtonsoft.com/json[
^]