How can an object from JavaScript convert to something similar to C #? How to make EnumerateProperties for COM?
For example, such an object {id:1, b:"20", c :{z:1}} ?
Ie, I want DeserializeBig("{id:1, b:"20", c :{z:1}}") ... it DeserializeBig("{id:1, b:"20", c :{z:1}}") out, but one detail is missing ...
Dictionary<string, object> io_data; Type TScriptControl; Dictionary<string, object> DeserializeBig(string query) { // Отправил обьект Dictionary<string, object> ret = new Dictionary<string, object>(); TScriptControl = Type.GetTypeFromProgID("ScriptControl"); object sc = TScriptControl.InvokeMember(null, System.Reflection.BindingFlags.CreateInstance, null, null, null); TScriptControl.InvokeMember("Language", System.Reflection.BindingFlags.SetProperty, null, sc, new object[] { "JavaScript" }); TScriptControl.InvokeMember("AddCode", System.Reflection.BindingFlags.InvokeMethod, null, sc, new object[] { "var x=" + query + ";" }); json = TScriptControl.InvokeMember("Eval", System.Reflection.BindingFlags.InvokeMethod, null, sc, new object[] { "x" }); io_data = ret; QueryKeyHlp("action"); QueryKeyHlp("id"); return ret; } void QueryKeyHlp(string id) { // узнаю есть ли у обьекта свойство. if (io_data.ContainsKey(id)) return; try { object q=TScriptControl.InvokeMember(id,System.Reflection.BindingFlags.GetProperty,null,json, null); if (q == null) return; if ((q is string)|| (q.GetType().IsPrimitive)) { io_data.Add(id, q); return; } To find out if the object has the 'a' property, you need to call QueryKeyHlp, i.e. actually execute GetProperty . How to make EnumerateProperties for COM?
I needed a large> 4MB JSon. Standard JavaScriptSerializer - does not eat. I do not ask Newton (I know that there is a Newton and many other different solutions). I lack a little bit to convert the object. Now I just request each property separately.