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