internal static JsonObject Create(object o, CultureInfo ci)
{
var obj = new JsonObject(ci);
object[] objArray;
Dictionary<string, object> dict;
Dictionary<string, string> sdict;
NameValueCollection nvc;
if ((objArray = o as object[]) != null)
{
obj._arrayData = new JsonObject[objArray.Length];
for (int i = 0; i < obj._arrayData.Length; ++i)
{
obj._arrayData[i] = Create(objArray[i], ci);
}
}
else if ((dict = o as Dictionary<string, object>) != null)
{
obj._dictData = new Dictionary<string, JsonObject>(dict.Count);
foreach (string key in dict.Keys)
{
obj._dictData[key] = Create(dict[key], ci);
}
}
else if ((sdict = o as Dictionary<string, string>) != null)
{
obj._dictData = new Dictionary<string, JsonObject>(sdict.Count);
foreach (string key in sdict.Keys)
{
obj._dictData[key] = new JsonObject(ci) { _stringData = sdict[key] };
}
}
else if ((nvc = o as NameValueCollection) != null)
{
obj._dictData = new Dictionary<string, JsonObject>(nvc.Count);
foreach (string key in nvc)
{
obj._dictData[key] = new JsonObject(ci) { _stringData = nvc[key] };
}
}
else if (o != null) // o is a scalar
{
obj._stringData = o.ToString();
}
return obj;
}