Mega Code Archive
Creates a JSON graph of all of the fields client-side data
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web.Script.Serialization;
using System.Web.UI;
public static class SerializationUtility
{
///
/// Creates a JSON graph of all of the field's client-side data.
///
public static string ToJson(this Dictionary> dict)
{
var main = new Dictionary>();
foreach (var item in dict)
{
var temp = new Dictionary();
foreach (var item2 in item.Value.Where(x => x.Value.ClientSide))
temp.Add(item2.Key, item2.Value.Value);
main.Add(item.Key, temp);
}
var json = new JavaScriptSerializer();
return json.Serialize(main);
}
}